R/tbl_hierarchical_rate_and_count.R
tbl_hierarchical_rate_and_count.RdA mix of adverse event rates (from gtsummary::tbl_hierarchical()) and counts
(from gtsummary::tbl_hierarchical_count()).
The function produces additional summary rows for the higher level nesting
variables providing both rates and counts.
When a hierarchical summary is filtered, the summary rows no longer provide
useful/consistent information.
When creating a filtered summary, use gtsummary::tbl_hierarchical() or
gtsummary::tbl_hierarchical_count() directly, followed by a call to
gtsummary::filter_hierarchical().
tbl_hierarchical_rate_and_count(
data,
variables,
denominator,
by = NULL,
id = "USUBJID",
label = NULL,
digits = NULL,
sort = NULL,
label_overall_rate = "Total number of participants with at least one adverse event",
label_overall_count = "Overall total number of events",
label_rate = "Total number of participants with at least one adverse event",
label_count = "Total number of events"
)
# S3 method for class 'tbl_hierarchical_rate_and_count'
add_overall(
x,
last = FALSE,
col_label = "All Participants \n(N = {style_roche_number(N)})",
...
)(data.frame)
a data frame.
(tidy-select)
Hierarchical variables to summarize. Must be 2 or 3 variables.
Typical inputs are c(AEBODSYS, AEDECOD) for an SOC/AE summary
or c(AEBODSYS, AEHLT, AEDECOD) for an SOC/HLT/AE summary.
Variables must be specified in the nesting order.
(data.frame, integer)
used to define the denominator and enhance the output.
The argument is required for tbl_hierarchical() and optional for tbl_hierarchical_count().
The denominator argument must be specified when id is used to calculate event rates.
(tidy-select)
a single column from data. Summary statistics will be stratified by this variable.
Default is NULL.
(tidy-select)
argument used to subset data to identify rows in data to calculate
event rates in tbl_hierarchical().
(formula-list-selector)
used to override default labels in hierarchical table, e.g. list(AESOC = "System Organ Class").
The default for each variable is the column label attribute, attr(., 'label').
If no label has been set, the column name is used.
(formula-list-selector)
Specifies how summary statistics are rounded. Values may be either integer(s) or function(s).
If a theme is applied, the digits specifications of the theme is applied.
Optional arguments passed to gtsummary::sort_hierarchical(sort).
(string)
String for the overall rate summary. Default is
"Total number of participants with at least one adverse event".
(string)
String for the overall count summary. Default is
"Overall total number of events".
(string)
String for the rate summary. Default is "Overall total number of events".
"Total number of participants with at least one adverse event".
(string)
String for the overall count summary. Default is "Total number of events".
(tbl_hierarchical_rate_and_count)
a stratified 'tbl_hierarchical_rate_and_count' table
(scalar logical)
Logical indicator to display overall column last in table.
Default is FALSE, which will display overall column first.
(string)
String indicating the column label. Default is "**Overall** \nN = {style_number(N)}"
These dots are for future extensions and must be empty.
a gtsummary table
# Example 1 ----------------------------------
cards::ADAE[c(1, 2, 3, 8, 16), ] |>
tbl_hierarchical_rate_and_count(
variables = c(AEBODSYS, AEDECOD),
denominator = cards::ADSL,
by = TRTA
) |>
add_overall(last = TRUE)
Body System or Organ Class
Dictionary-Derived Term
Placebo
(N = 86)
Xanomeline High Dose
(N = 84)
Xanomeline Low Dose
(N = 84)
All Participants
(N = 254)