nested_data_plot: Create a plot of nested sources of variation

Description Usage Arguments Details Examples

View source: R/plot-nested.R

Description

Creates a plot showing the breakdown of variation within a sample. This function uses ggplot2 internally.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
nested_data_plot(
  dat,
  x,
  groups = c(),
  stat = "mean",
  ...,
  y_gap = 1,
  divider_color = "grey50",
  point_args = list(),
  dline_args = list(),
  vline_args = list(),
  hline_args = list(),
  label_args = list(),
  connector_args = list()
)

Arguments

dat

a data.frame or similar object

x

the variable within dat to plot. Most often this would be a strength or modulus variable.

groups

a vector of variables to group the data by

stat

a function for computing the central location for each group. This is normally "mean" but could be "median" or another function.

...

extra options. See Details.

y_gap

the vertical gap between grouping variables

divider_color

the color of the lines between grouping variables. Or NULL to omit these lines.

point_args

arguments to pass to ggplot2::geom_point when plotting individual data points.

dline_args

arguments to pass to ggplot2::geom_segment when plotting the horizontal lines between data points.

vline_args

arguments to pass to ggplot2::geom_segment when plotting vertical lines

hline_args

arguments to pass to ggplot2::geom_segment when plotting horizontal lines connecting levels in groups

label_args

arguments to pass to ggplot2::geom_label when plotting labels

connector_args

arguments to pass to ggplot2::geom_point when plotting the connection between the vertical lines and the horizontal lines connecting levels in groups

Details

Extra options can be included to control aesthetic options. The following options are supported. Any (or all) can be set to a single variable in the data set.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(dplyr)
carbon.fabric.2 %>%
  filter(test == "WT" & condition == "RTD") %>%
  nested_data_plot(strength,
                   groups = c(batch, panel))

# Labels can be filled too
carbon.fabric.2 %>%
  filter(test == "WT" & condition == "RTD") %>%
  nested_data_plot(strength,
                   groups = c(batch, panel),
                   fill = batch)

cmstatr documentation built on Sept. 30, 2021, 5:08 p.m.