rename_cat_variables: Rename variables and/or their levels

View source: R/misc.R

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(data, var_names = NULL, level_names = NULL)

Arguments

data

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

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 data, with variables and/or levels renamed. Any variables where levels are renamed will be converted to factors.


LukasWallrich/timesaveR documentation built on Nov. 29, 2024, 4:47 a.m.