Skip to contents

mid.plots() applies ggmid() or plot() to the component functions of a "mid" object.

Usage

mid.plots(
  object,
  terms = mid.terms(object, interaction = FALSE),
  limits = c(NA, NA),
  intercept = FALSE,
  main.effects = FALSE,
  max.plots = NULL,
  engine = c("ggplot2", "graphics"),
  ...
)

Arguments

object

a "mid" object.

terms

a character vector. The names of the terms to be visualized.

limits

NULL or a numeric vector of length two specifying the limits of the plotting scale. NAs are replaced by the minimum and/or maximum MID values.

intercept

logical. If TRUE, the intercept is added to the MID values and the plotting scale is shifted.

main.effects

logical. If TRUE, the main effects are included in the interaction plot.

max.plots

an integer specifying the number of maximum number of plots.

engine

character string. One of "ggplot2" or "graphics".

...

optional parameters to be passed to ggmid() or plot().

Value

If engine is "ggplot2", mid.plots() returns a list of "ggplot" objects. Otherwise mid.plots() produces plots and returns NULL.

Examples

data(diamonds, package = "ggplot2")
set.seed(42)
idx <- sample(nrow(diamonds), 1e4L)
mid <- interpret(price ~ (carat + cut + color + clarity) ^ 2, diamonds[idx, ])
#> 'model' not passed: response variable in 'data' is used
mid.plots(mid, c("carat", "color", "carat:color", "clarity:color"), limits = NULL)
#> $carat

#> 
#> $color

#> 
#> $`carat:color`

#> 
#> $`clarity:color`

#>