Learn R Programming

colleyRstats (version 0.0.1)

stat_sum_df: Generating the sum and adding a crossbar.

Description

Generating the sum and adding a crossbar.

Usage

stat_sum_df(fun, geom = "crossbar", ...)

Value

A ggplot2 layer that can be added to a ggplot object.

Arguments

fun

function

geom

geom to be shown

...

Additional arguments passed to stat_summary

Examples

Run this code
# \donttest{
  # 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)
# }

Run the code above in your browser using DataLab