Functions ard_hierarchical() and ard_hierarchical_count() are primarily helper
functions for ard_stack_hierarchical() and ard_stack_hierarchical_count(),
meaning that it will be rare a user needs to call
ard_hierarchical()/ard_hierarchical_count() directly.
Performs hierarchical or nested tabulations, e.g. tabulates AE terms nested within AE system organ class.
ard_hierarchical()includes summaries for the last variable listed in thevariablesargument, nested within the other variables included.ard_hierarchical_count()includes summaries for all variables listed in thevariablesargument each summary nested within the preceding variables, e.g.variables=c(AESOC, AEDECOD)summarizesAEDECODnested inAESOC, and also summarizes the counts ofAESOC.
Usage
ard_hierarchical(data, ...)
ard_hierarchical_count(data, ...)
# S3 method for class 'data.frame'
ard_hierarchical(
data,
variables,
by = dplyr::group_vars(data),
statistic = everything() ~ c("n", "N", "p"),
denominator = NULL,
fmt_fun = NULL,
stat_label = everything() ~ default_stat_labels(),
id = NULL,
fmt_fn = deprecated(),
...
)
# S3 method for class 'data.frame'
ard_hierarchical_count(
data,
variables,
by = dplyr::group_vars(data),
fmt_fun = NULL,
stat_label = everything() ~ default_stat_labels(),
fmt_fn = deprecated(),
...
)Arguments
- data
(
data.frame)
a data frame- ...
Arguments passed to methods.
- variables
(
tidy-select)
variables to perform the nested/hierarchical tabulations within.- by
(
tidy-select)
variables to perform tabulations by. All combinations of the variables specified here appear in results. Default isdplyr::group_vars(data).- statistic
(
formula-list-selector)
a named list, a list of formulas, or a single formula where the list element one or more ofc("n", "N", "p", "n_cum", "p_cum")(on the RHS of a formula).- denominator
(
data.frame,integer)
used to define the denominator and enhance the output. The argument is required forard_hierarchical()and optional forard_hierarchical_count().the univariate tabulations of the
byvariables are calculated withdenominator, when a data frame is passed, e.g. tabulation of the treatment assignment counts that may appear in the header of a table.the
denominatorargument must be specified whenidis used to calculate the event rates.
- fmt_fun
(
formula-list-selector)
a named list, a list of formulas, or a single formula where the list element is a named list of functions (or the RHS of a formula), e.g.list(mpg = list(mean = \(x) round(x, digits = 2) |> as.character())).- stat_label
(
formula-list-selector)
a named list, a list of formulas, or a single formula where the list element is either a named list or a list of formulas defining the statistic labels, e.g.everything() ~ list(n = "n", p = "pct")oreverything() ~ list(n ~ "n", p ~ "pct").- id
(
tidy-select)
an optional argument used to assert there are no duplicates within thec(id, variables)columns.- fmt_fn
Examples
ard_hierarchical(
data = ADAE |>
dplyr::slice_tail(n = 1L, by = c(USUBJID, TRTA, AESOC, AEDECOD)),
variables = c(AESOC, AEDECOD),
by = TRTA,
id = USUBJID,
denominator = ADSL
)
#> # An ARD data frame: 2,178 × 13
#> group1 group1_level group2 group2_level variable variable_level stat_name
#> <chr> <list> <chr> <list> <chr> <list> <chr>
#> 1 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIAL FIBRIL… n
#> 2 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIAL FIBRIL… N
#> 3 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIAL FIBRIL… p
#> 4 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIAL FLUTTER n
#> 5 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIAL FLUTTER N
#> 6 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIAL FLUTTER p
#> 7 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIAL HYPERT… n
#> 8 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIAL HYPERT… N
#> 9 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIAL HYPERT… p
#> 10 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIOVENTRICU… n
#> # ℹ 2,168 more rows
#> # ℹ 6 more variables: context <chr>, stat_label <chr>, stat <list>,
#> # fmt_fun <list>, warning <list>, error <list>
ard_hierarchical_count(
data = ADAE,
variables = c(AESOC, AEDECOD),
by = TRTA
)
#> # An ARD data frame: 726 × 13
#> group1 group1_level group2 group2_level variable variable_level stat_name
#> <chr> <list> <chr> <list> <chr> <list> <chr>
#> 1 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIAL FIBRIL… n
#> 2 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIAL FLUTTER n
#> 3 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIAL HYPERT… n
#> 4 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIOVENTRICU… n
#> 5 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD ATRIOVENTRICU… n
#> 6 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD BRADYCARDIA n
#> 7 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD BUNDLE BRANCH… n
#> 8 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD BUNDLE BRANCH… n
#> 9 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD CARDIAC DISOR… n
#> 10 TRTA Placebo AESOC CARDIAC DISORDE… AEDECOD CARDIAC FAILU… n
#> # ℹ 716 more rows
#> # ℹ 6 more variables: context <chr>, stat_label <chr>, stat <list>,
#> # fmt_fun <list>, warning <list>, error <list>
