get_rename_tribbles: Get code to generate tibbles to rename categorical variables...

get_rename_tribblesR Documentation

Get code to generate tibbles to rename categorical variables and their levels

Description

Renaming categorical variables and their levels, for instance for summary tables, can be fiddly. This function generates code in which only the new names need to be modified, and which can then be passed to either rename_cat_variables or directly to cat_var_table_mi

Usage

get_rename_tribbles(
  dat,
  ...,
  show = TRUE,
  which = c("both", "vars", "levels"),
  max_levels = 20
)

Arguments

dat

A dataframe that contains the variables - only used to extract their possible levels.

...

The variables to be included in the rename tribbles.

show

Logical - should the output be printed to the console. In any case, it is returned invisibly

which

Should tribble code be generated for variables ("vars"), levels ("levels") or both ("both") (default)

max_levels

The maximum number of levels before a variable is dropped from the levels_tribble. Defaults to 20

Details

Only categorical variables should be passed to the function if code for levels is requested. If a variable has more than 20 distinct values, it is dropped from the levels-tribble-code

Value

Code to be edited and passed to tibble::tribble() to create var_names and level_names arguments for rename_cat_variables and cat_var_table_mi


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