mean_ci | R Documentation |
A function for calculating and formatting means and confidence interval.
mean_ci(
x,
na_rm = FALSE,
alpha = getOption("qwraps2_alpha", 0.05),
qdist = stats::qnorm,
qdist.args = list(),
...
)
## S3 method for class 'qwraps2_mean_ci'
print(x, ...)
x |
a numeric vector |
na_rm |
if true, omit NA values |
alpha |
defaults to |
qdist |
defaults to |
qdist.args |
list of arguments passed to |
... |
arguments passed to |
Given a numeric vector, mean_ci
will return a vector with the mean,
LCL, and UCL. Using frmtci
will be helpful for reporting the results
in print.
a vector with the mean, lower confidence limit (LCL), and the upper confidence limit (UCL).
frmtci
# using the standard normal for the CI
mean_ci(mtcars$mpg)
# print it nicely
qwraps2::frmtci(mean_ci(mtcars$mpg))
qwraps2::frmtci(mean_ci(mtcars$mpg), show_level = TRUE)
qwraps2::frmtci(mean_ci(mtcars$mpg, alpha = 0.01), show_level = TRUE)
# Compare to the ci that comes form t.test
t.test(mtcars$mpg)
t.test(mtcars$mpg)$conf.int
mean_ci(mtcars$mpg, qdist = stats::qt, qdist.args = list(df = 31))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.