powered by
Rename the levels of a categorical variables, and returns the result along with tidyverse code used to generate it.
renameLevels(.data, var, to_be_renamed, name = sprintf("%s.rename", var))
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 list of the old level name assigned to the new level name; i.e., `list('new level name' = 'old level name')`
a name for the new variable
Owen Jin
code
renamed <- renameLevels(iris, var = "Species", to_be_renamed = list(set = "setosa", ver = "versicolor")) cat(code(renamed)) head(renamed)
Run the code above in your browser using DataLab