add_ci {gtsummary} | R Documentation |
Add CI Column
Description
Add a new column with the confidence intervals for proportions, means, etc.
Usage
add_ci(x, ...)
## S3 method for class 'tbl_summary'
add_ci(
x,
method = list(all_continuous() ~ "t.test", all_categorical() ~ "wilson"),
include = everything(),
statistic = list(all_continuous() ~ "{conf.low}, {conf.high}", all_categorical() ~
"{conf.low}%, {conf.high}%"),
conf.level = 0.95,
style_fun = list(all_continuous() ~ label_style_sigfig(), all_categorical() ~
label_style_sigfig(scale = 100)),
pattern = NULL,
...
)
Arguments
x |
( |
... |
These dots are for future extensions and must be empty. |
method |
( |
include |
( |
statistic |
( |
conf.level |
(scalar |
style_fun |
( |
pattern |
( |
Value
gtsummary table
method argument
Must be one of
-
"wilson"
,"wilson.no.correct"
calculated viaprop.test(correct = c(TRUE, FALSE))
for categorical variables -
"exact"
calculated viastats::binom.test()
for categorical variables -
"wald"
,"wald.no.correct"
calculated viacardx::proportion_ci_wald(correct = c(TRUE, FALSE)
for categorical variables -
"agresti.coull"
calculated viacardx::proportion_ci_agresti_coull()
for categorical variables -
"jeffreys"
calculated viacardx::proportion_ci_jeffreys()
for categorical variables -
"t.test"
calculated viastats::t.test()
for continuous variables -
"wilcox.test"
calculated viastats::wilcox.test()
for continuous variables
Examples
# Example 1 ----------------------------------
trial |>
tbl_summary(
missing = "no",
statistic = all_continuous() ~ "{mean} ({sd})",
include = c(marker, response, trt)
) |>
add_ci()
# Example 2 ----------------------------------
trial |>
select(response, grade) %>%
tbl_summary(
statistic = all_categorical() ~ "{p}%",
missing = "no",
include = c(response, grade)
) |>
add_ci(pattern = "{stat} ({ci})") |>
modify_footnote(everything() ~ NA)