stat_sum_df: Generating the sum and adding a crossbar.

View source: R/utils.R

stat_sum_dfR Documentation

Generating the sum and adding a crossbar.

Description

Generating the sum and adding a crossbar.

Usage

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

Arguments

fun

function

geom

geom to be shown

...

Additional arguments passed to stat_summary

Value

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

Examples


  # 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)


colleyRstats documentation built on May 3, 2026, 5:07 p.m.