Get formatted means and confidence intervals by group
Source:R/basic_functions.R
table_mean_conf_by.RdGet formatted means and confidence intervals by group
Value
An array of list entries, with dimensions and dimension names
determined by the levels of the grouping variables in by. Each observed
group contains the two-element character vector returned by table_mean_conf;
unobserved combinations contain NULL.
Examples
# Group means for continuous data
x <- rnorm(100, mean = 50, sd = 10)
groups <- rep(c("A", "B", "C"), length.out = 100)
table_mean_conf_by(x, groups)
#> $A
#> [1] "49.96" "[46.39, 52.90]"
#>
#> $B
#> [1] "47.10" "[43.93, 50.26]"
#>
#> $C
#> [1] "45.93" "[41.78, 49.69]"
#>
# Group means for binary data
y <- rbinom(100, 1, prob = 0.7)
table_mean_conf_by(y, groups, binom = TRUE)
#> $A
#> [1] "0.62" "[0.45, 0.76]"
#>
#> $B
#> [1] "0.76" "[0.59, 0.87]"
#>
#> $C
#> [1] "0.64" "[0.47, 0.78]"
#>