[R] Plotting 1 covariate, 3 factors

Richard M. Heiberger rmh at temple.edu
Wed Oct 7 19:12:00 CEST 2009


## Paul

## I think you are looking for interaction2wt

y <- rnorm(36)
f1 <- rep(c("after", "before"), 18)
f2 <- rep(1:3, 12)
f3 <- rep(1:2, each=18)

## your definition of ff was faulty.  It gave a constant.
f3.f1 <- interaction(f3, f1)
interaction.plot(f3.f1, f2, y)

f2 <- factor(f2)
f3 <- factor(f3)

## lattice would be better
xyplot(y ~ f2 | f3, groups=f2)


## if you don't have HH, you will need to install it and its dependencies
## install.packages("HH")
## You may need to close R and restart R

require(HH)
interaction2wt(y ~ f1 + f2 + f3)

position(f1) <- c(1.5, 2.5)
position(f3) <- c(1.5, 2.5)
interaction2wt(y ~ f1 + f2 + f3, box.ratio=.6)

## Rich




More information about the R-help mailing list