[R] Trouble plotting interaction with brkdn.plot from plotrix package
Miksza, Peter John
pmiksza at indiana.edu
Wed Mar 16 02:13:22 CET 2016
Hello,
I'm exploring different ways to plot interactions for mixed-design ANOVA and am having difficulty getting the brkdn.plot() function in the R plotrix package to work.
The interaction.plot() is working fine, but I'd really like to be able to customize the plot more as the brkdn.plot() function seems to be able to do.
Any help pointing out my error(s) would be much appreciated.
Pete Miksza
IU Jacobs School of Music, Bloomington, IN
Here is an example of my code:
set.seed(1976)
Y = rnorm(1600, 5, 2)
A = c(rep(1, 200), rep(2, 200), rep(1, 200), rep(2, 200), rep(1, 200), rep(2, 200), rep(1, 200), rep(2, 200))
B = c(rep(1, 400), rep(2, 400), rep(3, 400), rep(4, 400))
A = factor(A, levels = c(1, 2), labels = c("Treat", "Control"))
B = factor(B, levels = c(1, 2, 3, 4), labels = c("One", "Two", "Three", "Four"))
dat = data.frame(Y, A, B)
str(dat)
# I can't figure out why this doesn't work
library(plotrix)
brkdn.plot("dat$Y", "dat$B", "dat$A", data = dat)
# this works
interaction.plot(dat$B, dat$A, dat$Y, fun = mean)
[[alternative HTML version deleted]]
More information about the R-help
mailing list