rename_levels: Rename the levels of a categorical variable

View source: R/mutate.R

rename_levelsR 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

rename_levels(data, var, tobe_asis, name = NULL)

Arguments

data

a dataframe with the column to be renamed

var

a character of the categorical variable to rename

tobe_asis

a named list of the old level names assigned to the new level names ie. list('new level names' = 'old level names')

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)

Zhaoming Su

See Also

code

Examples

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


iNZightVIT/iNZightTools documentation built on April 8, 2024, 10:25 a.m.