factor_to_numeric: Change the type of the column of a dataframe from factor to...

View source: R/utility_functions.R

factor_to_numericR Documentation

Change the type of the column of a dataframe from factor to numeric

Description

Change the type of the column of a dataframe from factor to numeric

Usage

factor_to_numeric(df, factor_name)

Arguments

df

Dataframe.

factor_name

Vector of names of factors to change to numeric.

Value

Same dataframe with type of the given columns changed to numeric.

Examples

df <- data.frame(A = rep(1:5, each = 10))
df$A <- factor(df$A)
str(df)
df <- factor_to_numeric(df, "A")
str(df)

ghurault/HuraultMisc documentation built on Dec. 9, 2024, 10:39 a.m.