Learn R Programming

easyr (version 0.3-1)

char2fac: Characters to Factors

Description

Convert all character columns in a data frame to factors. Author: Bryce Chamberlain.

Usage

char2fac(x, sortlevels = FALSE, na_level = "(Missing)")

Arguments

x

Data frame (or tibble) to modify.

sortlevels

Choose whether to sort levels. This is the default R behavior and is therefore likely faster, but it may change the order of the data and this can be problematic so the default is FALSE.

na_level

dplyr doesn't like factors to have NAs so we replace NAs with this value for factors only. Set NULL to skip.

Value

Data frame (or tibble) with converted factors.

Examples

Run this code
# NOT RUN {
char2fac( iris )
# }

Run the code above in your browser using DataLab