add_overall: Add column with overall summary statistics

Description Usage Arguments Value Example Output Author(s) See Also Examples

View source: R/add_overall.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
add_overall(x, ...)

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

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

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

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

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.

Value

A tbl_* of same class as x

Example Output

Example 1

Example 2

Example 3

Author(s)

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_custom_summary tools: continuous_summary(), proportion_summary(), ratio_summary(), tbl_custom_summary()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
tbl_overall_ex1 <-
  trial %>%
  tbl_summary(include = c(age, grade), by = trt) %>%
  add_overall()
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)
  )
tbl_overall_ex3 <-
 trial %>%
 tbl_continuous(
   variable = age,
   by = trt,
   include = grade
 ) %>%
 add_overall(last = TRUE)

gtsummary documentation built on Jan. 21, 2022, 1:09 a.m.