plotDesign: Plot of the design matrix

View source: R/plotDesign.R

plotDesignR Documentation

Plot of the design matrix

Description

Provides a graphical representation of the experimental design for up to 4 factors. It allows to visualize factors levels and check the balancing of the design.

Usage

plotDesign(
  design,
  x = NULL,
  y = NULL,
  rows = NULL,
  cols = NULL,
  title = "Plot of the design",
  theme = theme_bw()
)

Arguments

design

A nxk "free encoded" experimental design data frame.

x

By default: the first column of design. If not NULL, a character string giving the column name of design to be used for the x axis.

y

By default: the second column of design. If not NULL, a character string giving the column name of design to be used for the y axis.

rows

By default: the fourth column of design if present. If not NULL, a character vector with one or several column name(s) of design to be used for faceting along the rows.

cols

By default: the third column of design if present. If not NULL, a character vector with one or several column name(s) of design to be used for faceting along the columns.

title

Plot title.

theme

ggplot theme, see ?ggtheme for more info.

Value

A plot of the design (ggplot).

Examples


### mtcars
data(mtcars)
library(tidyverse)
df <-  mtcars %>%
  dplyr::select(cyl, vs, am, gear, carb) %>%
  as.data.frame() %>%
  dplyr::mutate(across(everything(), as.factor))

# 2 factors
plotDesign(design = df, x = "cyl", y = "vs",
          cols = NULL, rows = NULL)
# 3 factors
plotDesign(design = df, x = "cyl", y = "vs",
          cols = NULL, rows = c("am"))
# 4 factors
plotDesign(design = df, x = "cyl", y = "vs",
          cols = c("gear"), rows = c("am"))
# 5 factors
plotDesign(design = df, x = "cyl", y = "vs",
          cols = c("gear"), rows = c("am","carb"))

plotDesign(design = df, x = "cyl", y = "vs",
          cols = c("vs"), rows = c("am","carb"))

### UCH
data("UCH")
plotDesign(design = UCH$design, x = "Hippurate", y = "Citrate", rows = "Day")


bgovaerts/LMWiRe documentation built on Sept. 17, 2022, 12:32 a.m.