Skip to content
Prev 172592 / 398525 Next

adding value labels on Interaction Plot

Thank you, David, however, I am not sure this approach works.
Let's try it again - I slightly modifed d to make it more clear:

d=data.frame(xx=c(1,1,1,1,2,2,2,2,3,3,3,3),yy=c(3,3,4,4,3,3,4,4,3,3,4,4),zz=c(-1.1,-1.3,0,0.6,-0.5,1,3.3,-1.3,4.4,3.5,5.1,3.5))
d[[1]]<-as.factor(d[[1]])
d[[2]]<-as.factor(d[[2]])
print(d)

interaction.plot(d$xx, d$yy, d$zz, fun=mean,
  type="b", col=c("red","blue"), legend=F,
  lty=c(1,2), lwd=2, pch=c(18,24),
  xlab="X Label (level of xx)",
  ylab="Y Label (level of zz)",
  main="Chart Label")

grid(nx=NA, ny=NULL,col = "lightgray", lty = "dotted",
     lwd = par("lwd"), equilogs = TRUE)

legend("bottomright",c("3","4"),bty="n",lty=c(1,2),lwd=2,
pch=c(18,24),col=c("red","blue"),title="Level of yy")


The dots on both lines show means on zz for a given combination of
factors xx and yy.

# If I add this line:
with(d, text(xx,zz,paste(zz)))
It adds the zz values for ALL data points in d - instead of the means
that are shown on the graph...
Any advice?

Dimitri


d=data.frame(xx=c(3,3,3,2,2,2,1,1,1),yy=c(4,3,4,3,4,3,4,3,4),zz=c(5.1,4.4,3.5,3.3,-1.1,-1.3,0,-0.5,0.6))
d[[1]]<-as.factor(d[[1]])
d[[2]]<-as.factor(d[[2]])
print(d)

interaction.plot(d$xx, d$yy, d$zz, fun=mean,
  type="b", col=c("red","blue"), legend=F,
  lty=c(1,2), lwd=2, pch=c(18,24),
  xlab="X Label",
  ylab="Y Label",
  main="Chart Label")

grid(nx=NA, ny=NULL,col = "lightgray", lty = "dotted",
     lwd = par("lwd"), equilogs = TRUE)

legend("bottomright",c("0.25","0.50","0.75"),bty="n",lty=c(1,2,3),lwd=2,
pch=c(18,24,22),col=c(PrimaryColors[c(6,4)],SecondaryColors[c(4)]),title="R
Squared")
On Wed, Mar 4, 2009 at 2:06 PM, David Winsemius <dwinsemius at comcast.net> wrote: