tab_ci {tabxplor} | R Documentation |
Add confidence intervals to a tab
Description
Add confidence intervals to a tab
Usage
tab_ci(
tabs,
ci = "auto",
comp = NULL,
conf_level = 0.95,
color = "no",
visible = FALSE,
method_cell = "wilson",
method_diff = "ac"
)
Arguments
tabs |
|
ci |
The type of ci to calculate. Set to "cell" to calculate absolute confidence
intervals. Set to "diff" to calculate the confidence intervals of the difference
between a cell and the relative total cell (or the reference cell,
when |
comp |
Comparison level. When |
conf_level |
The confidence level, as a single numeric between 0 and 1. Default to 0.95 (95%). |
color |
The type of colors to print, as a single string.
|
visible |
By default confidence intervals are calculated and used to set colors,
but not printed. Set to |
method_cell |
Character string specifying which method to use with percentages
for |
method_diff |
Character string specifying which method to use with percentages
for |
Value
A tibble
of class tab
, colored based on differences (from
totals/first cells) and confidence intervals.
Examples
# A typical workflow with tabxplor step-by-step functions :
data <- dplyr::starwars %>%
tab_prepare(sex, hair_color, gender, rare_to_other = TRUE,
n_min = 5, na_drop_all = sex)
data %>%
tab_plain(sex, hair_color, gender, tot = c("row", "col"),
pct = "row", comp = "all") %>%
tab_ci("diff", color = "after_ci")