| add_n_summary {gtsummary} | R Documentation | 
Add column with N
Description
For each variable in a tbl_summary table, the add_n function adds a column with the
total number of non-missing (or missing) observations
Usage
## S3 method for class 'tbl_summary'
add_n(
  x,
  statistic = "{N_nonmiss}",
  col_label = "**N**",
  footnote = FALSE,
  last = FALSE,
  ...
)
## S3 method for class 'tbl_svysummary'
add_n(
  x,
  statistic = "{N_nonmiss}",
  col_label = "**N**",
  footnote = FALSE,
  last = FALSE,
  ...
)
Arguments
| x | ( | 
| statistic | ( 
 The argument uses  | 
| col_label | ( | 
| footnote | (scalar  | 
| last | (scalar  | 
| ... | These dots are for future extensions and must be empty. | 
Value
A table of class c('tbl_summary', 'gtsummary')
Author(s)
Daniel D. Sjoberg
Examples
# Example 1 ----------------------------------
trial |>
  tbl_summary(by = trt, include = c(trt, age, grade, response)) |>
  add_n()
# Example 2 ----------------------------------
survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq) |>
  tbl_svysummary(by = Survived, percent = "row", include = c(Class, Age)) |>
  add_n()