powered by
Rename the levels of a categorical variables, and returns the result along with tidyverse code used to generate it.
rename_levels(data, var, tobe_asis, name = NULL)
original dataframe containing a new column of the renamed categorical variable with tidyverse code attached
a dataframe with the column to be renamed
a character of the categorical variable to rename
a named list of the old level names assigned to the new level names ie. list('new level names' = 'old level names')
a name for the new variable
Zhaoming Su
code
renamed <- rename_levels(iris, var = "Species", tobe_asis = list(set = "setosa", ver = "versicolor") ) cat(code(renamed)) head(renamed)
Run the code above in your browser using DataLab