Learn R Programming

cards (version 0.6.1)

rename_ard_columns: Rename ARD Variables

Description

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
)

Value

data frame

Arguments

x

(data.frame)
an ARD data frame of class 'card'

columns

(tidy-select)
columns to rename, e.g. selecting columns c('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 the fill argument. Default is c(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 with glue::glue() where the colname element is available to inject into the string, e.g. 'Overall {colname}' may resolve to 'Overall AGE' for an AGE column. Default is '{colname}'.

unlist

[Deprecated]

Examples

Run this code
# Example 1 ----------------------------------
ADSL |>
  ard_categorical(by = ARM, variables = AGEGR1) |>
  apply_fmt_fun() |>
  rename_ard_columns() |>
  unlist_ard_columns()

# Example 2 ----------------------------------
ADSL |>
  ard_continuous(by = ARM, variables = AGE) |>
  apply_fmt_fun() |>
  rename_ard_columns(fill = "Overall {colname}") |>
  unlist_ard_columns()

Run the code above in your browser using DataLab