Skip to contents

[Experimental]
General function for calculating ARD results within subgroups.

While the examples below show use with other functions from the cards package, this function would primarily be used with the statistical functions in the cardx functions.

Usage

ard_strata(.data, .by = NULL, .strata = NULL, .f, ...)

Arguments

.data

(data.frame)
a data frame

.by, .strata

(tidy-select)
columns to tabulate by/stratify by for calculation. Arguments are similar, but with an important distinction:

.by: results are tabulated by all combinations of the columns specified, including unobserved combinations and unobserved factor levels.

.strata: results are tabulated by all observed combinations of the columns specified.

These argument should not include any columns that appear in the .f argument.

.f

(function, formula)
a function or a formula that can be coerced to a function with rlang::as_function() (similar to purrr::map(.f))

...

Additional arguments passed on to the .f function.

Value

an ARD data frame of class 'card'

Examples

ard_strata(
  ADSL,
  by = ARM,
  .f = ~ ard_continuous(.x, variables = AGE)
)
#> {cards} data frame: 8 x 8
#>   variable   context stat_name stat_label   stat fmt_fn
#> 1      AGE continuo…         N          N    254      0
#> 2      AGE continuo…      mean       Mean 75.087      1
#> 3      AGE continuo…        sd         SD  8.246      1
#> 4      AGE continuo…    median     Median     77      1
#> 5      AGE continuo…       p25         Q1     70      1
#> 6      AGE continuo…       p75         Q3     81      1
#> 7      AGE continuo…       min        Min     51      1
#> 8      AGE continuo…       max        Max     89      1
#>  2 more variables: warning, error