Learn R Programming

SciencesPo (version 1.3.9)

safe.chars: Convert All Factor Columns to Character Columns

Description

By default, R converts character columns to factors. Instead of re-reading the data using stringsAsFactors, the safe.chars function will identify which columns are currently factors, and convert them all to characters.

Usage

safe.chars(.data)

Arguments

.data
The name of the data.frame

See Also

read.table, destring.

Examples

Run this code
str(iris)
iris_2 = safe.chars(iris)
str(iris_2)

Run the code above in your browser using DataLab