This function combines a pair of group
/group_level
or variable
/variable_level
columns into a
single column. The group_level
or variable_level
column is renamed according to the value of
the group
or variable
column, respectively.
Usage
rename_ard_columns(
x,
columns = c(all_ard_groups(), all_ard_variables()),
unlist = NULL
)
Arguments
- x
(
data.frame
)
a data frame- columns
(
tidy-select
)
Name of columns to coalesce together and rename.- unlist
(
tidy-select
)
Columns to unlist. Often useful when performing visual inspection of the results where the list-columns are more difficult to work with.
Examples
ADSL |>
ard_categorical(by = ARM, variables = AGEGR1) |>
apply_fmt_fn() |>
rename_ard_columns(unlist = c(stat, stat_fmt))
#> # 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 Xanomelin… 65-80 catego… n n 55 55 <int> <NULL>
#> 5 Xanomelin… 65-80 catego… N N 84 84 <int> <NULL>
#> 6 Xanomelin… 65-80 catego… p % 0.655 65.5 <fn> <NULL>
#> 7 Xanomelin… 65-80 catego… n n 47 47 <int> <NULL>
#> 8 Xanomelin… 65-80 catego… N N 84 84 <int> <NULL>
#> 9 Xanomelin… 65-80 catego… p % 0.560 56.0 <fn> <NULL>
#> 10 Placebo <65 catego… n n 14 14 <int> <NULL>
#> # ℹ 17 more rows
#> # ℹ 1 more variable: error <list>