View source: R/add_ci.tbl_svysummary.R
add_ci.tbl_svysummary | R Documentation |
Add a new column with the confidence intervals for proportions, means, etc.
## S3 method for class 'tbl_svysummary'
add_ci(
x,
method = list(all_continuous() ~ "svymean", all_categorical() ~ "svyprop.logit"),
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,
df = survey::degf(x$inputs$data),
...
)
x |
( |
method |
( |
include |
( |
statistic |
( |
conf.level |
(scalar |
style_fun |
( |
pattern |
( |
df |
( |
... |
These dots are for future extensions and must be empty. |
gtsummary table
Must be one of
"svyprop.logit"
, "svyprop.likelihood"
, "svyprop.asin"
,
"svyprop.beta"
, "svyprop.mean"
, "svyprop.xlogit"
calculated via survey::svyciprop()
for categorical variables
"svymean"
calculated via survey::svymean()
for continuous variables
"svymedian.mean"
, "svymedian.beta"
, "svymedian.xlogit"
,
"svymedian.asin"
, "svymedian.score"
calculated via survey::svyquantile(quantiles = 0.5)
for continuous variables
data(api, package = "survey")
survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) |>
tbl_svysummary(
by = "both",
include = c(api00, stype),
statistic = all_continuous() ~ "{mean} ({sd})"
) |>
add_stat_label() |>
add_ci(pattern = "{stat} (95% CI {ci})") |>
modify_header(all_stat_cols() ~ "**{level}**") |>
modify_spanning_header(all_stat_cols() ~ "**Survived**")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.