[R] simple line graphics, labels and legend

Jim Lemon jim at bitwrit.com.au
Wed Mar 17 02:15:09 CET 2010


Hi Ivan,
You can get your first plot this way:

plot(test$SILIKATG, ylim=c(0,0.02), type="l",xaxt="n",xlab="Group")
axis(1,at=c(5,10,15,20),labels=sort(unique(test$DIET)))

I was going to suggest using reshape to get the following matrix, but I 
just couldn't work out how to do it.

test.wide<-cbind(test$SILIKATG[test$DIET=="G"],
  test$SILIKATG[test$DIET=="GG"],
  test$SILIKATG[test$DIET=="L"],
  test$SILIKATG[test$DIET=="LG"])
matplot(test.wide,pch="")
text(rep(1:5,4),test.wide,rep(c("G","GG","L","LG"),each=5),
  col=rep(2:5,each=5))

Jim



More information about the R-help mailing list