renameLevels {iNZightTools}R Documentation

Rename the levels of a categorical variable

Description

Rename the levels of a categorical variables, and returns the result along with tidyverse code used to generate it.

Usage

renameLevels(.data, var, to_be_renamed, name = sprintf("%s.rename", var))

Arguments

.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

Value

original dataframe containing a new column of the renamed categorical variable with tidyverse code attached

Author(s)

Owen Jin

See Also

code

Examples

Run examples

renamed <- renameLevels(iris, var = "Species",
    to_be_renamed = list(set = "setosa", ver = "versicolor"))
cat(code(renamed))
head(renamed)


[Package iNZightTools version 1.12.2 Index]