View source: R/add_difference.tbl_hierarchical.R
| add_difference.tbl_hierarchical | R Documentation |
Add a column of event-rate differences to a table created with
tbl_hierarchical() or tbl_ard_hierarchical(). For every node in the
hierarchy (e.g. each system organ class and each preferred term) the event
rate of a second by group is subtracted from the rate of a first by group.
This is a wrapper around cards::diff_ard_hierarchical().
The table must be stratified by a single by variable and its statistics must
include the rate (p) statistic (the default for tbl_hierarchical()).
## S3 method for class 'tbl_hierarchical'
add_difference(
x,
levels = NULL,
statistic = "{estimate}%",
estimate_fun = label_style_number(digits = 1, scale = 100),
...
)
## S3 method for class 'tbl_ard_hierarchical'
add_difference(
x,
levels = NULL,
statistic = "{estimate}%",
estimate_fun = NULL,
...
)
x |
( |
levels |
( |
statistic |
( |
estimate_fun |
( |
... |
These dots are for future extensions and must be empty. |
a gtsummary table of the same class as x
# Example 1 ----------------------------------
# rate difference between two treatment arms
ADAE_subset <- cards::ADAE |>
dplyr::filter(AESOC %in% unique(cards::ADAE$AESOC)[1:5]) |>
dplyr::filter(.by = AESOC, AEDECOD %in% unique(cards::ADAE$AEDECOD)[1:5])
tbl_hierarchical(
data = ADAE_subset,
variables = c(AESOC, AEDECOD),
by = TRTA,
denominator = cards::ADSL,
id = USUBJID
) |>
add_difference(levels = c("Xanomeline High Dose", "Placebo"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.