Learn R Programming

cards (version 0.3.0)

update_ard: Update ARDs

Description

Functions used to update ARD formatting functions and statistic labels.

This is a helper function to streamline the update process. If it does not exactly meet your needs, recall that an ARD is just a data frame and it can be modified directly.

Usage

update_ard_fmt_fn(
  x,
  variables = everything(),
  stat_names,
  fmt_fn,
  filter = TRUE
)

update_ard_stat_label( x, variables = everything(), stat_names, stat_label, filter = TRUE )

Value

an ARD data frame of class 'card'

Arguments

x

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

variables

(tidy-select)
variables in x$variable to apply update. Default is everything().

stat_names

(character)
character vector of the statistic names (i.e. values from x$stat_name) to apply the update.

fmt_fn

(function)
a function or alias recognized by alias_as_fmt_fn().

filter

(expression)
an expression that evaluates to a logical vector identifying rows in x to apply the update to. Default is TRUE, and update is applied to all rows.

stat_label

(function)
a string of the updated statistic label.

Examples

Run this code
ard_continuous(ADSL, variables = AGE) |>
  update_ard_fmt_fn(stat_names = c("mean", "sd"), fmt_fn = 8L) |>
  update_ard_stat_label(stat_names = c("mean", "sd"), stat_label = "Mean (SD)") |>
  apply_fmt_fn()

# same as above, but only apply update to the Placebo level
ard_continuous(
  ADSL,
  by = ARM,
  variables = AGE,
  statistic = ~ continuous_summary_fns(c("N", "mean"))
) |>
  update_ard_fmt_fn(stat_names = "mean", fmt_fn = 8L, filter = group1_level == "Placebo") |>
  apply_fmt_fn()

Run the code above in your browser using DataLab