e_data_convert_factor_to_numeric: Convert all factor variables to their numeric factor levels

View source: R/e_data_convert_factor_to_numeric.R

e_data_convert_factor_to_numericR Documentation

Convert all factor variables to their numeric factor levels

Description

When saving to csv, the default data class/type for factors is the character labels. This function replaces those with the numeric factor levels.

Usage

e_data_convert_factor_to_numeric(dat)

Arguments

dat

data.frame or tibble

Value

dat with factor variables converted to numeric

Examples

dat <- dat_mtcars_e
str(dat)

dat2 <- dat |> e_data_convert_factor_to_numeric()
str(dat2)

# readr::write_csv(x = dat , file = "dat.csv"    )
# readr::write_csv(x = dat2, file = "dat_num.csv")

erikerhardt/erikmisc documentation built on April 17, 2025, 10:48 a.m.