| stat_sum_df | R Documentation |
Generating the sum and adding a crossbar.
stat_sum_df(fun, geom = "crossbar", ...)
fun |
function |
geom |
geom to be shown |
... |
Additional arguments passed to stat_summary |
A ggplot2 layer that can be added to a ggplot object.
# Simple summary function: use the mean as y, ymin, and ymax
mean_fun <- function(x) {
m <- mean(x, na.rm = TRUE)
data.frame(y = m, ymin = m, ymax = m)
}
ggplot2::ggplot(mtcars, ggplot2::aes(x = factor(cyl), y = mpg)) +
stat_sum_df(mean_fun)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.