get_rename_tribbles | R Documentation |
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 report_cat_vars()
get_rename_tribbles(
data,
...,
show = TRUE,
which = c("both", "vars", "levels"),
max_levels = 20
)
data |
A dataframe that contains the variables - only used to extract their possible levels. |
... |
The variables to be included in the rename tribbles. If none are
specified, all are included, unless there are more than |
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 ( |
max_levels |
The maximum number of levels before a variable is dropped from the levels_tribble. Defaults to 20 |
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, unless the max_levels argument is increased.
Code to be edited and passed to tibble::tribble() to create var_names and level_names arguments for
rename_cat_variables()
and report_cat_vars()
. 'New' variable and level names are minimally
transformed, but are primarily intended to be placeholders.
get_rename_tribbles(iris)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.