tidybayes (version 1.0.4)

stat_pointinterval: Point summary + multiple probability interval plots (ggplot stat)

Description

A combination of stat_summary / stat_summaryh and geom_pointinterval / geom_pointintervalh with sensible defaults. While the corresponding geoms are intended for use on data frames that have already been summarized using a point_interval function, these stats are intended for use directly on data frames of draws, and will perform the summarization using a point_interval function.

Usage

stat_pointinterval(mapping = NULL, data = NULL,
  geom = "pointinterval", position = "identity", ...,
  point_interval = median_qi, fun.data = NULL, .width = c(0.66,
  0.95), .prob, fun.args = list(), na.rm = FALSE,
  show.legend = c(size = FALSE), inherit.aes = TRUE)

stat_pointintervalh(mapping = NULL, data = NULL, geom = "pointintervalh", position = "identity", ..., point_interval = median_qi, fun.data = NULL, .width = c(0.66, 0.95), .prob, fun.args = list(), na.rm = FALSE, show.legend = c(size = FALSE), 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_pointinterval/geom_pointintervalh and stat_pointinterval/stat_pointintervalh.

position

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

...

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

point_interval

A function that when given a vector should return a data frame with variables y, ymin, ymax, and .width; or x, xmin, xmax, and .width. Either is acceptable: output will be converted into the y-based aesthetics for stat_pointinterval and the x-based aesthetics for stat_pointintervalh. 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, the x and y-based aesthetics are not converted to the correct form automatically.

.width

The .width argument passed to point_interval.

.prob

Deprecated. Use .width instead.

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? Default is c(size = FALSE), unlike most geoms, to match its common use cases. FALSE hides all legends, TRUE shows all legends, and NA shows only those that are mapped (the default for most geoms).

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 behavior from the default plot specification, e.g. borders.

See Also

See geom_pointinterval / geom_pointintervalh for the geom versions, intended for use on points and intervals that have already been summarized using a point_interval function. See stat_interval / stat_intervalh for a similar stat intended for intervals without point summaries.

Examples

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

data(RankCorr, package = "tidybayes")

RankCorr %>%
  spread_draws(u_tau[i]) %>%
  ggplot(aes(y = i, x = u_tau)) +
  stat_pointintervalh(.width = c(.66, .95))

RankCorr %>%
  spread_draws(u_tau[i]) %>%
  ggplot(aes(x = i, y = u_tau)) +
  stat_pointinterval(.width = c(.66, .95))

# }

Run the code above in your browser using DataLab