repeatedMeasuresPlot: Plot Means for Repeated-Measures ANOVA Designs

View source: R/repeatedMeasuresPlot.R

repeatedMeasuresPlotR Documentation

Plot Means for Repeated-Measures ANOVA Designs

Description

Creates a means plot for a repeated-measures ANOVA design with one or two within-subjects factor and zero or more between-subjects factors, for data in "wide" format.

Usage

repeatedMeasuresPlot(data, within, within.names, within.levels, 
    between.names = NULL, response.name = "score", trace, xvar, 
    pch=15:25, lty=1:6, col=palette()[-1], 
    plot.means=TRUE, print.tables = FALSE)

Arguments

data

a data frame in wide format.

within

a character vector with the names of the data columns containing the repeated measures.

within.names

a character vector with one or two elements, of names of the within-subjects factor(s).

within.levels

a named list whose elements are character vectors of level names for the within-subjects factors, with names corresponding to the names of the within-subjects factors; the product of the numbers of levels should be equal to the number of repeated-measures columns in within.

between.names

a column vector of names of the between-subjects factors (if any).

response.name

optional quoted name for the response variable, defaults to "score".

trace

optional quoted name of the (either within- or between-subjects) factor to define profiles of means in each panel of the graph; the default is the within-subjects factor with the smaller number of levels, if there are two, or not used if there is one.

xvar

optional quoted name of the factor to define the horizontal axis of each panel; the default is the within-subjects factor with the larger number of levels.

pch, lty

vectors of symbol and line-type numbers to use for the profiles of means (i.e., levels of the trace factor); for the meaning of the defaults, see points and par.

col

vector of colors for the profiles of means; the default is given by palette(), starting at the second color.

plot.means

if TRUE (the default), draw a plot of means by the factors.

print.tables

if TRUE (the default is FALSE), print tables of means and standard deviations of the response by the factors.

Value

A "trellis" object, which normally is just "printed" (i.e., plotted).

Author(s)

John Fox jfox@mcmaster.ca

See Also

Anova, OBrienKaiser

Examples

if (require(carData)){
repeatedMeasuresPlot(
  data=OBrienKaiser, 
  within=c("pre.1", "pre.2", "pre.3", "pre.4", "pre.5",
          "post.1", "post.2", "post.3", "post.4", "post.5",
          "fup.1", "fup.2", "fup.3", "fup.4", "fup.5"), 
  within.names=c("phase", "hour"), 
  within.levels=list(phase=c("pre", "post", "fup"),
                    hour = c("1", "2", "3", "4", "5")),
  between.names=c("gender", "treatment"),
  response.name="improvement",
  print.tables=TRUE)
}

if (require(carData)){
repeatedMeasuresPlot(data=OBrienKaiser, 
  within=c("pre.1", "pre.2", "pre.3", "pre.4", "pre.5",
          "post.1", "post.2", "post.3", "post.4", "post.5",
          "fup.1", "fup.2", "fup.3", "fup.4", "fup.5"), 
  within.names=c("phase", "hour"), 
  within.levels=list(phase=c("pre", "post", "fup"),
                    hour = c("1", "2", "3", "4", "5")),
  between.names=c("gender", "treatment"),
  trace="gender") # note that gender is between subjects
}

if (require(carData)){
repeatedMeasuresPlot(
  data=OBrienKaiser, 
  within=c("fup.1", "fup.2", "fup.3", "fup.4", "fup.5"), 
  within.names="hour", 
  within.levels=list(hour = c("1", "2", "3", "4", "5")),
  between.names=c("treatment", "gender"),
  response.name="improvement")
}

RcmdrMisc documentation built on Sept. 27, 2023, 1:06 a.m.