Rename the grouping and variable columns to their original column names.
Usage
rename_ard_columns(
x,
columns = c(all_ard_groups("names"), all_ard_variables("names")),
fill = "{colname}",
unlist = NULL
)Arguments
- x
(
data.frame)
an ARD data frame of class 'card'- columns
(
tidy-select)
columns to rename, e.g. selecting columnsc('group1', 'group2', 'variable')will rename'group1_level'to the name of the variable found in'group1'. When, for example, the'group1_level'does not exist, the values of the new column are filled with the values in thefillargument. Default isc(all_ard_groups("names"), all_ard_variables("names")).- fill
(scalar/glue)
a scalar to fill column values when the variable does not have levels. If a character is passed, then it is processed withglue::glue()where thecolnameelement is available to inject into the string, e.g.'Overall {colname}'may resolve to'Overall AGE'for an AGE column. Default is'{colname}'.- unlist
Examples
# Example 1 ----------------------------------
ADSL |>
ard_categorical(by = ARM, variables = AGEGR1) |>
apply_fmt_fn() |>
rename_ard_columns() |>
unlist_ard_columns()
#> # A tibble: 27 × 10
#> ARM AGEGR1 context stat_name stat_label stat stat_fmt fmt_fn warning
#> <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <list> <list>
#> 1 Placebo 65-80 catego… n n 42 42 <int> <NULL>
#> 2 Placebo 65-80 catego… N N 86 86 <int> <NULL>
#> 3 Placebo 65-80 catego… p % 0.488 48.8 <fn> <NULL>
#> 4 Placebo <65 catego… n n 14 14 <int> <NULL>
#> 5 Placebo <65 catego… N N 86 86 <int> <NULL>
#> 6 Placebo <65 catego… p % 0.163 16.3 <fn> <NULL>
#> 7 Placebo >80 catego… n n 30 30 <int> <NULL>
#> 8 Placebo >80 catego… N N 86 86 <int> <NULL>
#> 9 Placebo >80 catego… p % 0.349 34.9 <fn> <NULL>
#> 10 Xanomelin… 65-80 catego… n n 55 55 <int> <NULL>
#> # ℹ 17 more rows
#> # ℹ 1 more variable: error <list>
# Example 2 ----------------------------------
ADSL |>
ard_continuous(by = ARM, variables = AGE) |>
apply_fmt_fn() |>
rename_ard_columns(fill = "Overall {colname}") |>
unlist_ard_columns()
#> # A tibble: 24 × 10
#> ARM AGE context stat_name stat_label stat stat_fmt fmt_fn warning error
#> <chr> <chr> <chr> <chr> <chr> <dbl> <chr> <list> <list> <list>
#> 1 Plac… Over… contin… N N 86 86 <int> <NULL> <NULL>
#> 2 Plac… Over… contin… mean Mean 75.2 75.2 <int> <NULL> <NULL>
#> 3 Plac… Over… contin… sd SD 8.59 8.6 <int> <NULL> <NULL>
#> 4 Plac… Over… contin… median Median 76 76.0 <int> <NULL> <NULL>
#> 5 Plac… Over… contin… p25 Q1 69 69.0 <int> <NULL> <NULL>
#> 6 Plac… Over… contin… p75 Q3 82 82.0 <int> <NULL> <NULL>
#> 7 Plac… Over… contin… min Min 52 52.0 <int> <NULL> <NULL>
#> 8 Plac… Over… contin… max Max 89 89.0 <int> <NULL> <NULL>
#> 9 Xano… Over… contin… N N 84 84 <int> <NULL> <NULL>
#> 10 Xano… Over… contin… mean Mean 74.4 74.4 <int> <NULL> <NULL>
#> # ℹ 14 more rows
