Learn R Programming

cards (version 0.9.0)

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}",
  fct_as_chr = TRUE,
  unlist = NULL
)

Value

a data frame of class 'card_renamed'

Arguments

x

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

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}'.

fct_as_chr

(scalar logical)
When TRUE, factor elements will be converted to character before unlisting. When the column being unlisted contains mixed types of classes, the factor elements are often converted to the underlying integer value instead of retaining the label. Default is TRUE.

unlist

[Deprecated]

Examples

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

# Example 2 ----------------------------------
ADSL |>
  ard_summary(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