add_hierarchical_count_row: Add row with counts

View source: R/add_hierarchical_count_row.R

add_hierarchical_count_rowR Documentation

Add row with counts

Description

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

Usage

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)

crane documentation built on Aug. 30, 2025, 1:12 a.m.