Skip to contents

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 the variables argument, nested within the other variables included.

  • ard_hierarchical_count() includes summaries for all variables listed in the variables argument each summary nested within the preceding variables, e.g. variables=c(AESOC, AETERM) summarizes AETERM nested in AESOC, and also summarizes the counts of AESOC.

Usage

ard_hierarchical(
  data,
  variables,
  by = dplyr::group_vars(data),
  statistic = everything() ~ categorical_summary_fns(),
  denominator = NULL,
  fmt_fn = NULL,
  stat_label = everything() ~ default_stat_labels()
)

ard_hierarchical_count(
  data,
  variables,
  by = dplyr::group_vars(data),
  fmt_fn = NULL,
  stat_label = everything() ~ default_stat_labels()
)

Arguments

data

(data.frame)
a data frame

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 is dplyr::group_vars(data).

statistic

(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 = categorical_summary_fns()).

denominator

(data.frame, integer)
Specify this optional argument to change the denominator, e.g. the "N" statistic. Default is NULL. See below for details.

fmt_fn

(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") or everything() ~ list(n ~ "n", p ~ "pct").

Value

an ARD data frame of class 'card'

Examples

ard_hierarchical(
  data = ADAE,
  variables = c(AESOC, AETERM),
  by = c(TRTA, AESEV),
  denominator = ADSL |> dplyr::rename(TRTA = ARM)
)
#> {cards} data frame: 6534 x 15
#>    group1 group1_level group2 group2_level group3 group3_level variable
#> 1    TRTA      Placebo  AESEV         MILD  AESOC    GENERAL …   AETERM
#> 2    TRTA      Placebo  AESEV         MILD  AESOC    GENERAL …   AETERM
#> 3    TRTA      Placebo  AESEV         MILD  AESOC    GENERAL …   AETERM
#> 4    TRTA    Xanomeli…  AESEV         MILD  AESOC    GENERAL …   AETERM
#> 5    TRTA    Xanomeli…  AESEV         MILD  AESOC    GENERAL …   AETERM
#> 6    TRTA    Xanomeli…  AESEV         MILD  AESOC    GENERAL …   AETERM
#> 7    TRTA    Xanomeli…  AESEV         MILD  AESOC    GENERAL …   AETERM
#> 8    TRTA    Xanomeli…  AESEV         MILD  AESOC    GENERAL …   AETERM
#> 9    TRTA    Xanomeli…  AESEV         MILD  AESOC    GENERAL …   AETERM
#> 10   TRTA      Placebo  AESEV     MODERATE  AESOC    GENERAL …   AETERM
#>    variable_level stat_name stat_label  stat
#> 1       APPLICAT…         n          n     3
#> 2       APPLICAT…         N          N    86
#> 3       APPLICAT…         p          % 0.035
#> 4       APPLICAT…         n          n    16
#> 5       APPLICAT…         N          N    84
#> 6       APPLICAT…         p          %  0.19
#> 7       APPLICAT…         n          n     9
#> 8       APPLICAT…         N          N    84
#> 9       APPLICAT…         p          % 0.107
#> 10      APPLICAT…         n          n     0
#>  6524 more rows
#>  Use `print(n = ...)` to see more rows
#>  4 more variables: context, fmt_fn, warning, error

ard_hierarchical_count(
  data = ADAE,
  variables = c(AESOC, AETERM),
  by = TRTA
)
#> {cards} data frame: 795 x 13
#>    group1 group1_level group2 group2_level variable variable_level stat_name
#> 1    TRTA      Placebo  AESOC    GENERAL …   AETERM      APPLICAT…         n
#> 2    TRTA    Xanomeli…  AESOC    GENERAL …   AETERM      APPLICAT…         n
#> 3    TRTA    Xanomeli…  AESOC    GENERAL …   AETERM      APPLICAT…         n
#> 4    TRTA      Placebo  AESOC    GENERAL …   AETERM      APPLICAT…         n
#> 5    TRTA    Xanomeli…  AESOC    GENERAL …   AETERM      APPLICAT…         n
#> 6    TRTA    Xanomeli…  AESOC    GENERAL …   AETERM      APPLICAT…         n
#> 7    TRTA      Placebo  AESOC    GASTROIN…   AETERM      DIARRHOEA         n
#> 8    TRTA    Xanomeli…  AESOC    GASTROIN…   AETERM      DIARRHOEA         n
#> 9    TRTA    Xanomeli…  AESOC    GASTROIN…   AETERM      DIARRHOEA         n
#> 10   TRTA      Placebo  AESOC    SKIN AND…   AETERM       ERYTHEMA         n
#>    stat_label stat
#> 1           n    3
#> 2           n   23
#> 3           n   20
#> 4           n   10
#> 5           n   35
#> 6           n   33
#> 7           n   10
#> 8           n    4
#> 9           n    7
#> 10          n   13
#>  785 more rows
#>  Use `print(n = ...)` to see more rows
#>  4 more variables: context, fmt_fn, warning, error