gtsummary (version 1.6.3)

add_overall: Add column with overall summary statistics

Description

Adds a column with overall summary statistics to tables created by tbl_summary, tbl_svysummary, tbl_continuous or tbl_custom_summary.

Usage

add_overall(x, ...)

# S3 method for tbl_summary add_overall( x, last = FALSE, col_label = NULL, statistic = NULL, digits = NULL, ... )

# S3 method for tbl_svysummary add_overall( x, last = FALSE, col_label = NULL, statistic = NULL, digits = NULL, ... )

# S3 method for tbl_continuous add_overall( x, last = FALSE, col_label = NULL, statistic = NULL, digits = NULL, ... )

# S3 method for tbl_custom_summary add_overall( x, last = FALSE, col_label = NULL, statistic = NULL, digits = NULL, ... )

Value

A tbl_* of same class as x

Arguments

x

Object with class tbl_summary from the tbl_summary function, object with class tbl_svysummary from the tbl_svysummary function, object with class tbl_continuous from the tbl_continuous function or object with class tbl_custom_summary from the tbl_custom_summary function.

...

Not used

last

Logical indicator to display overall column last in table. Default is FALSE, which will display overall column first.

col_label

String indicating the column label. Default is "**Overall**, N = {N}"

statistic

Override the statistic argument in initial tbl_* function. call. Default is NULL.

digits

Override the digits argument in initial tbl_* function call. Default is NULL.

Example Output

Example 1

image of rendered example table

Example 2

image of rendered example table

Example 3

image of rendered example table

Author

Daniel D. Sjoberg

See Also

Other tbl_summary tools: add_ci(), add_n.tbl_summary(), add_p.tbl_summary(), add_q(), add_stat_label(), bold_italicize_labels_levels, inline_text.tbl_summary(), inline_text.tbl_survfit(), modify, separate_p_footnotes(), tbl_custom_summary(), tbl_merge(), tbl_split(), tbl_stack(), tbl_strata(), tbl_summary()

Other tbl_svysummary tools: add_n.tbl_summary(), add_p.tbl_svysummary(), add_q(), add_stat_label(), modify, separate_p_footnotes(), tbl_merge(), tbl_split(), tbl_stack(), tbl_strata(), tbl_svysummary()

Other tbl_continuous tools: add_p.tbl_continuous(), tbl_continuous()

Other tbl_custom_summary tools: continuous_summary(), proportion_summary(), ratio_summary(), tbl_custom_summary()

Examples

Run this code
# \donttest{
# Example 1 ----------------------------------
tbl_overall_ex1 <-
  trial %>%
  tbl_summary(include = c(age, grade), by = trt) %>%
  add_overall()

# Example 2 ----------------------------------
tbl_overall_ex2 <-
  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)
  )

# Example 3 ----------------------------------
tbl_overall_ex3 <-
  trial %>%
  tbl_continuous(
    variable = age,
    by = trt,
    include = grade
  ) %>%
  add_overall(last = TRUE)
# }

Run the code above in your browser using DataLab