Learn R Programming

gtsummary (version 1.6.1)

add_ci: Add CI Column

Description

Add a new column with the confidence intervals for proportions, means, etc.

Usage

add_ci(x, ...)

# S3 method for tbl_summary add_ci( x, method = NULL, include = everything(), statistic = NULL, conf.level = 0.95, style_fun = NULL, pattern = NULL, ... )

Value

gtsummary table

method argument

Methods c("wilson", "wilson.no.correct") are calculated with prop.test(correct = c(TRUE, FALSE)). The default method, "wilson", includes the Yates continuity correction. Methods c("exact", "asymptotic") are calculated with Hmisc::binconf(method=). Confidence intervals for means are calculated using t.test() and wilcox.test() for pseudo-medians.

Example Output

Example 1

Example 2

See Also

Review list, formula, and selector syntax used throughout gtsummary

Other tbl_summary tools: add_n.tbl_summary(), add_overall(), 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()

Examples

Run this code
# NOT RUN {
# Example 1 ----------------------------------
add_ci_ex1 <-
  trial %>%
  select(marker, response, trt) %>%
  tbl_summary(missing = "no",
              statistic = all_continuous() ~ "{mean} ({sd})") %>%
  add_ci()

# Example 2 ----------------------------------
add_ci_ex2 <-
  trial %>%
    select(response, grade) %>%
    tbl_summary(statistic = all_categorical() ~ "{p}%",
                missing = "no") %>%
    add_ci(pattern = "{stat} ({ci})") %>%
    modify_footnote(everything() ~ NA)
# }

Run the code above in your browser using DataLab