rename_cat_variables: Rename variables and/or their levels

rename_cat_variablesR Documentation

Rename variables and/or their levels

Description

Renaming categorical variables and their levels, for instance for summary tables, can be fiddly. This function accepts tibbles containing the old and new names for arguments and levels, and returns a dataframe (or list of dataframes, if one is passed) with variables and levels renamed.

Usage

rename_cat_variables(dat, ..., var_names = NULL, level_names = NULL)

Arguments

dat

A dataframe or list of dataframes (e.g., from multiple imputation) contains the variables. If a list is passed, it must have class "list"

...

The variables to be renamed

var_names

A tibble containing 'old' and 'new' names for the variables. If NULL, only levels are renamed.

level_names

A tibble containing old 'var' names and 'level_old' and 'level_new' names. If NULL, only variables are renamed.

Value

The dataframe or list of dataframes passed to dat, with variables and/or levels renamed


LukasWallrich/rNuggets documentation built on Aug. 26, 2022, 11:03 a.m.