Learn R Programming

iNZightTools (version 1.13.0)

convertToCat: Convert numeric variables to categorical

Description

Convert specified numeric variables into factors

Usage

convertToCat(.data, vars, names = paste(vars, "cat", sep = "."))

Value

original dataframe containing a new column of the converted numeric variable with tidyverse code attached

Arguments

.data

a dataframe with the categorical column to convert

vars

a character vector of numeric column names to convert

names

a character vector of names for the created variable(s)

Author

Owen Jin

See Also

code

Examples

Run this code
converted <- convertToCat(iris, vars = c("Petal.Width"))
cat(code(converted))
head(converted)

Run the code above in your browser using DataLab