Adds a column with overall summary statistics to tables
created by tbl_ard_summary().
Usage
# S3 method for class 'tbl_ard_summary'
add_overall(
x,
cards,
last = FALSE,
col_label = "**Overall**",
statistic = NULL,
...
)Arguments
- x
(
tbl_ard_summary)
A stratified 'gtsummary' table- cards
(
card)
An ARD object of class"card"typically created withcards::ard_*()functions.- last
(scalar
logical)
Logical indicator to display overall column last in table. Default isFALSE, which will display overall column first.- col_label
(
string)
String indicating the column label. Default is"**Overall**"- statistic
(
formula-list-selector)
Override the statistic argument in initialtbl_*function call. Default isNULL.- ...
These dots are for future extensions and must be empty.
Examples
# Example 1 ----------------------------------
# build primary table
tbl <-
cards::ard_stack(
trial,
.by = trt,
cards::ard_summary(variables = age),
cards::ard_tabulate(variables = grade),
.missing = TRUE,
.attributes = TRUE,
.total_n = TRUE
) |>
tbl_ard_summary(by = trt)
# create ARD with overall results
ard_overall <-
cards::ard_stack(
trial,
cards::ard_summary(variables = age),
cards::ard_tabulate(variables = grade),
.missing = TRUE,
.attributes = TRUE,
.total_n = TRUE
)
# add an overall column
tbl |>
add_overall(cards = ard_overall)
Characteristic
Overall1
Drug A1
Drug B1
1 Median (Q1, Q3); n (%)
