stat_summarise: Summarise by grouping variable

Description Usage Format Examples

View source: R/stats.r

Description

Applies a function to a specified grouping variable

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
stat_summarise(
  mapping = NULL,
  data = NULL,
  geom = "bar",
  position = "identity",
  ...,
  fun = NULL,
  fun.args = list(),
  show.legend = NA,
  inherit.aes = TRUE
)

stat_summarize(
  mapping = NULL,
  data = NULL,
  geom = "bar",
  position = "identity",
  ...,
  fun = NULL,
  fun.args = list(),
  show.legend = NA,
  inherit.aes = TRUE
)

Format

An object of class Summarise (inherits from Stat, ggproto, gg) of length 5.

An object of class Summarize (inherits from Stat, ggproto, gg) of length 5.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#library(tidyr)
i <- gather(iris,"key","value",-Species)
ggplot(i, aes(Species, fill = key, domain = value)) +
   geom_bar(aes(y = after_stat(summarise)), stat = "summarise") +
   stat_summarise(aes(y = after_stat(summarise),
                  label = after_stat(summarise)),
                  position = position_stack(vjust = .5), geom = "text")
ggplot(i, aes(key, fill = Species, domain = value)) +
   geom_bar(aes(y = after_stat(summarise)), stat = "summarise") +
   stat_summarise(aes(y = after_stat(summarise),
                  label = after_stat(summarise)),
                  position = position_stack(vjust = .5), geom = "text")

jtlandis/ggsidebar documentation built on Nov. 24, 2020, 7:22 p.m.