The geom_jitter_failure_mode is very similar to ggplot2::geom_jitter() except that a failure mode variable specified as the color and/or shape aesthetic is parsed to separate multiple failure modes and plot them separately. For example, if an observation has the failure mode "LAT/LAB", two points will be plotted, one with the failure mode "LAT" and the second with the failure mode "LAB".

geom_jitter_failure_mode(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "jitter",
  ...,
  width = NULL,
  height = NULL,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE,
  sep = "[/, ]+"
)

Arguments

mapping

Set of aesthetic mapping created by aes(). See ggplot2::geom_jitter() for additional details.

data

The data to be displayed by this layer. See ggplot2::geom_jitter() for additional details.

stat

The statistical transformation to use on the data for this layer. See ggplot2::geom_jitter() for additional details.

position

A position adjustment to use on the data for this layer. See ggplot2::geom_jitter() for additional details.

...

Other arguments passed on to layer()'s params argument. See ggplot2::geom_jitter() for additional details.

width

The amount of horizontal jitter. See ggplot2::geom_jitter() for additional details.

height

The amount of vertical jitter. See ggplot2::geom_jitter() for additional details.

na.rm

If FALSE, the default, missing values are removed with warning. See ggplot2::geom_jitter() for additional details.

show.legend

NA, the default, indicates that nay aesthetics are mapped. See ggplot2::geom_jitter() for additional details.

inherit.aes

if FALSE, overrides the default aesthetics. See ggplot2::geom_jitter() for additional details.

sep

A regular expression indicating the character(s) separating multiple failure modes. By default "[/, ]+"

Details

The variable specified for the aesthetics shape and color are passed to the function separate_failure_modes() to parse the failure modes and separate multiple failure modes separated by character(s) specified in the regular expression given in the parameter sep. By default, multiple failure modes are expected to be separated by spaces, commas or forward slashes, but this can be overridden.

If both shape and color aesthetics are specified, both must be identical.

Examples

library(dplyr)
library(ggplot2)
carbon.fabric.2 %>%
  filter(test == "WT") %>%
  ggplot(aes(x = condition, y = strength)) +
  geom_boxplot() +
  geom_jitter_failure_mode(aes(color = failure_mode, shape = failure_mode))