plotMeans: Means plot

View source: R/plotMeans.R

plotMeansR Documentation

Means plot

Description

Draws, for a given response variable, a plot of the response means by levels of up to three categorical factors of the design. When the design is balanced, it allows to visualize main effects or interactions for the response of interest. For unbalanced designs, this plot must be used with caution.

Usage

plotMeans(
  Y,
  design,
  cols = NULL,
  x,
  z = NULL,
  w = NULL,
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  color = NULL,
  shape = NULL,
  linetype = NULL,
  size = 2,
  hline = NULL,
  theme = theme_bw()
)

Arguments

Y

A numerical matrix containing the columns to be drawn.

design

A nxk "free encoded" experimental design data frame.

cols

A vector with either the column name(s) of the Y matrix to plot (character) or the column index position(s).

x

A character string giving the design factor whose levels will form the x axis.

z

A character string giving the design factor whose levels will form the traces.

w

A character string giving the design factor whose levels will be used for the facet.

title

Plot title.

xlab

If not NULL, label for the x-axis.

ylab

If not NULL, label for the y-axis.

color

If not NULL, argument giving the color of the points and the line.

shape

If not NULL, argument giving the points shape.

linetype

If not NULL, argument giving the line type.

size

Argument of length 1 giving the points size.

hline

If not NULL, draws (a) horizontal line(s).

theme

ggplot theme, see ?ggtheme for more info.

Value

A means plot (ggplot).

Examples


# 1 factor
plotMeans(Y = UCH$outcomes, design = UCH$design, cols = "4.0628702",
          x = "Hippurate", color = "blue")

# 2 factors
plotMeans(Y = UCH$outcomes, design = UCH$design, cols = c(364,365),
          x = "Hippurate", z = "Time", shape = c(15,1))

# 3 factors
plotMeans(Y = UCH$outcomes, design = UCH$design, cols = c(364,365),
          x = "Hippurate", z = "Time", w = "Citrate", linetype = c(3,3))


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