powered by
Convert specified numeric variables into factors
convertToCat(.data, vars, names = paste(vars, "cat", sep = "."))
original dataframe containing a new column of the converted numeric variable with tidyverse code attached
a dataframe with the categorical column to convert
a character vector of numeric column names to convert
a character vector of names for the created variable(s)
Owen Jin
code
converted <- convertToCat(iris, vars = c("Petal.Width")) cat(code(converted)) head(converted)
Run the code above in your browser using DataLab