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
)
Arguments
- x
(
data.frame
)
an ARD data frame of class 'card'- variables
(
tidy-select
)
variables inx$variable
to apply update. Default iseverything()
.- stat_names
(
character
)
character vector of the statistic names (i.e. values fromx$stat_name
) to apply the update.- fmt_fn
(
function
)
a function or alias recognized byalias_as_fmt_fn()
.- filter
(
expression
)
an expression that evaluates to a logical vector identifying rows inx
to apply the update to. Default isTRUE
, and update is applied to all rows.- stat_label
(
function
)
a string of the updated statistic label.
Examples
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()
#> {cards} data frame: 8 x 9
#> variable context stat_name stat_label stat stat_fmt
#> 1 AGE continuo… N N 254 254
#> 2 AGE continuo… mean Mean (SD) 75.087 75.08661417
#> 3 AGE continuo… sd Mean (SD) 8.246 8.24623390
#> 4 AGE continuo… median Median 77 77.0
#> 5 AGE continuo… p25 Q1 70 70.0
#> 6 AGE continuo… p75 Q3 81 81.0
#> 7 AGE continuo… min Min 51 51.0
#> 8 AGE continuo… max Max 89 89.0
#> ℹ 3 more variables: fmt_fn, warning, error
# 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()
#> {cards} data frame: 6 x 11
#> group1 group1_level variable stat_name stat_label stat stat_fmt
#> 1 ARM Placebo AGE N N 86 86
#> 2 ARM Placebo AGE mean Mean 75.209 75.20930233
#> 3 ARM Xanomeli… AGE N N 84 84
#> 4 ARM Xanomeli… AGE mean Mean 74.381 74.4
#> 5 ARM Xanomeli… AGE N N 84 84
#> 6 ARM Xanomeli… AGE mean Mean 75.667 75.7
#> ℹ 4 more variables: context, fmt_fn, warning, error