Adds a column with overall summary statistics to tables
created by tbl_summary(), tbl_svysummary(), tbl_continuous() or
tbl_custom_summary().
add_overall(x, ...)
# S3 method for class 'tbl_summary'
add_overall(
x,
last = FALSE,
col_label = "**Overall** \nN = {style_number(N)}",
statistic = NULL,
digits = NULL,
...
)
# S3 method for class 'tbl_continuous'
add_overall(
x,
last = FALSE,
col_label = "**Overall** \nN = {style_number(N)}",
statistic = NULL,
digits = NULL,
...
)
# S3 method for class 'tbl_svysummary'
add_overall(
x,
last = FALSE,
col_label = "**Overall** \nN = {style_number(N)}",
statistic = NULL,
digits = NULL,
...
)
# S3 method for class 'tbl_custom_summary'
add_overall(
x,
last = FALSE,
col_label = "**Overall** \nN = {style_number(N)}",
statistic = NULL,
digits = NULL,
...
)
# S3 method for class 'tbl_hierarchical'
add_overall(
x,
last = FALSE,
col_label = "**Overall** \nN = {style_number(N)}",
statistic = NULL,
digits = NULL,
...
)
# S3 method for class 'tbl_hierarchical_count'
add_overall(
x,
last = FALSE,
col_label = ifelse(rlang::is_empty(x$inputs$denominator), "**Overall**",
"**Overall** \nN = {style_number(N)}"),
statistic = NULL,
digits = NULL,
...
)(tbl_summary, tbl_svysummary, tbl_continuous, tbl_custom_summary)
A stratified 'gtsummary' table
These dots are for future extensions and must be empty.
(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)}"
(formula-list-selector)
Override the statistic argument in initial tbl_* function
call. Default is NULL.
(formula-list-selector)
Override the digits argument in initial tbl_* function
call. Default is NULL.
A gtsummary of same class as x
# Example 1 ----------------------------------
trial |>
tbl_summary(include = c(age, grade), by = trt) |>
add_overall()
Characteristic
Overall
N = 2001
Drug A
N = 981
Drug B
N = 1021
1 Median (Q1, Q3); n (%)
# Example 2 ----------------------------------
trial |>
tbl_summary(
include = grade,
by = trt,
percent = "row",
statistic = ~"{p}%",
digits = ~1
) |>
add_overall(
last = TRUE,
statistic = ~"{p}% (n={n})",
digits = ~ c(1, 0)
)
Characteristic
Drug A
N = 981
Drug B
N = 1021
Overall
N = 2002
1 %
2 % (n=n)
# Example 3 ----------------------------------
trial |>
tbl_continuous(
variable = age,
by = trt,
include = grade
) |>
add_overall(last = TRUE)
Characteristic
Drug A
N = 981
Drug B
N = 1021
Overall
N = 2001
1 Age: Median (Q1, Q3)