renameLevels {iNZightTools} | R Documentation |
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))
.data |
a dataframe with the column to be renamed |
var |
a character of the categorical variable to rename |
to_be_renamed |
a list of the old level name assigned to the new level name; i.e., ‘list(’new level name' = 'old level name')' |
name |
a name for the new variable |
original dataframe containing a new column of the renamed categorical variable with tidyverse code attached
Owen Jin
renamed <- renameLevels(iris, var = "Species",
to_be_renamed = list(set = "setosa", ver = "versicolor"))
cat(code(renamed))
head(renamed)