stat_median_ci {tern}R Documentation

Confidence interval for median

Description

[Stable]

Convenient function for calculating the median confidence interval. It can be used as a ggplot helper function for plotting.

Usage

stat_median_ci(x, conf_level = 0.95, na.rm = TRUE, gg_helper = TRUE)

Arguments

x

(numeric)
vector of numbers we want to analyze.

conf_level

(proportion)
confidence level of the interval.

na.rm

(flag)
whether NA values should be removed from x prior to analysis.

gg_helper

(flag)
whether output should be aligned for use with ggplots.

Details

This function was adapted from ⁠DescTools/versions/0.99.35/source⁠

Value

A named vector of values median_ci_lwr and median_ci_upr.

Examples

stat_median_ci(sample(10), gg_helper = FALSE)

p <- ggplot2::ggplot(mtcars, ggplot2::aes(cyl, mpg)) +
  ggplot2::geom_point()
p + ggplot2::stat_summary(
  fun.data = stat_median_ci,
  geom = "errorbar"
)


[Package tern version 0.9.4 Index]