Learn R Programming

gtsummary (version 1.2.0)

add_n: 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

add_n(x, missing = FALSE, last = FALSE)

Arguments

x

Object with class tbl_summary from the tbl_summary function

missing

Logical argument indicating whether to print N (missing = FALSE), or N missing (missing = TRUE). Default is FALSE

last

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

Value

A tbl_summary object

Example Output

See Also

Other tbl_summary tools: add_overall, add_p, add_q.tbl_summary, add_stat_label, bold_italicize_labels_levels, bold_p.tbl_summary, inline_text.tbl_summary, modify_header, sort_p.tbl_summary, tbl_summary

Examples

Run this code
# NOT RUN {
tbl_n_ex <-
  trial %>%
  dplyr::select(trt, age, grade, response) %>%
  tbl_summary(by = trt) %>%
  add_n()
# }

Run the code above in your browser using DataLab