Learn R Programming

tidybayes (version 0.12.1.9000)

stat_lineribbon: Line + multiple probability ribbon stat for ggplot

Description

A combination of stat_summary and geom_lineribbon with sensible defaults. While geom_lineribbon is intended for use on data frames that have already been summarized using a point_interval function, stat_lineribbon is intended for use directly on data frames of samples, and will perform the summarization using a point_interval function.

Usage

stat_lineribbon(mapping = NULL, data = NULL, geom = "lineribbon",
  position = "identity", ..., point_interval = median_qi, fun.data = NULL,
  .prob = c(0.5, 0.8, 0.95), fun.args = list(), na.rm = FALSE,
  show.legend = NA, inherit.aes = TRUE)

Arguments

mapping

The aesthetic mapping, usually constructed with aes or aes_string. Only needs to be set at the layer level if you are overriding the plot defaults.

data

A layer specific dataset - only needed if you want to override the plot defaults.

geom

Use to override the default connection between geom_lineribbon and stat_lineribbon.

position

The position adjustment to use for overlapping points on this layer.

...

Other arguments passed to layer. They may also be parameters to the paired geom.

point_interval

A function that when given a vector should return a data frame with variables y, ymin, ymax, and .prob; or x, xmin, xmax, and .prob. Either is acceptable: output will be converted into the y-based aesthetics. See the point_interval family of functions.

fun.data

Similar to point_interval, for compatibility with stat_summary. Note: if the summary function is passed using fun.data, x-based aesthetics are not converted to the correct form automatically.

.prob

The .prob argument passed to fun.data.

fun.args

Other optional arguments passed to fun.data.

na.rm

If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

show.legend

Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders.

See Also

See geom_lineribbon for the geom version, intended for use on estimates/intervals that have already been summarized using a point_interval function. See stat_pointinterval / stat_pointintervalh for a similar stat intended for point estimates and intervals.

Examples

Run this code
# NOT RUN {
library(dplyr)
library(ggplot2)

data_frame(x = 1:10) %>%
  group_by_all() %>%
  do(data_frame(y = rnorm(100, .$x))) %>%
  ggplot(aes(x = x, y = y)) +
  stat_lineribbon() +
  scale_fill_brewer()

# }

Run the code above in your browser using DataLab