Skip to content
Prev 155466 / 398513 Next

plotting group means

On 9/9/2008 6:49 AM, Erich Studerus wrote:
Here is an approach which uses xyplot() in the lattice package and
shows how to control line types and colors:

mydf <- data.frame(x=rep(paste("Group", 1:4, sep=""), 6),
                   v=rep(paste("Variable", 1:6, sep=""), each=4),
                   y=runif(24))

library(lattice)

xyplot(y ~ v, groups = x, data = mydf, type="b",
              xlab="Dependent Variables", ylab="Mean",
              auto.key=list(lines=TRUE, points=TRUE, space="right"),
              par.settings = list(superpose.symbol =
                                   list(pch=c(16,8,1,5),
                                        col=c("black","red","green","blue"),
                                        lty=c(1,2,3,4)),
                                  superpose.line =
                                   list(col=c("black","red","green","blue"),
                                        lty=c(1,2,3,4))))