Typically used to add a row with overall AE counts to a table that primarily displays AE rates.

add_hierarchical_count_row(
  x,
  label = "Overall total number of events",
  .before = NULL,
  .after = NULL,
  data_preprocess = identity
)

Arguments

x

(gtsummary)
a gtsummary table

label

(string)
label for the new row

.before, .after

(integer)
Row index where to add the new row. Default is after last row.

data_preprocess

(function or formula)
a function that is applied to x$inputs$data before the total row counts are tabulated. Default is identity. Tidyverse formula shortcut notation for the function is accepted. See rlang::as_function() for details.

Value

gtsummary table

Examples

# Example 1 ----------------------------------
cards::ADAE |>
  # subset the data for a shorter example table
  dplyr::slice(1:10) |>
  tbl_hierarchical(
    by = "TRTA",
    variables = AEDECOD,
    denominator = cards::ADSL,
    id = "USUBJID",
    overall_row = TRUE
  ) |>
  add_hierarchical_count_row(.after = 1L)
Dictionary-Derived Term Placebo
N = 86
1
Xanomeline High Dose
N = 84
1
Number of patients with event 2 (2.3%) 2 (2.4%)
Overall total number of events 7 3
APPLICATION SITE ERYTHEMA 1 (1.2%) 1 (1.2%)
APPLICATION SITE PRURITUS 1 (1.2%) 2 (2.4%)
ATRIOVENTRICULAR BLOCK SECOND DEGREE 1 (1.2%) 0 (0%)
DIARRHOEA 1 (1.2%) 0 (0%)
ERYTHEMA 1 (1.2%) 0 (0%)
1 n (%)