Without the actual data, it's hard to see what's going on here, but It
seems you have to restructure your data object to a "long" table, then
it should be easy to use 'dotplot' to generate your plots.
...Tao
----- Original Message ----> From: Dimitri Liakhovitski <dimitri.liakhovitski at gmail.com>
> To: r-help at r-project.org
> Sent: Fri, May 14, 2010 10:19:38 AM
> Subject: [R] Putting 6 graphs on one page
>
> Apologies, if it's a very simple question, but I am really not very
good with > trellis.
I have a piece of a code (below) that works just fine and builds
> 6
graphs - in a loop. I loop through 6 conditions and build one graph
for > each.
What would be the most efficient way of creating one page with
> 6
graphs instead? (2 rows and 3 columns)?
Thanks a > lot!
Dimitri
conditions<-c("a","b","c","d","e","f")
conditions.long<-c("It's > a","It's b","It's c","It's
d","It's e","It's f")
for(i in 1:6) > {
> IV<-conditions[i]
filename2=paste("DependentVariable > ","IV ",IV,".emf",sep="")
> win.metafile(file=filename2)
> out<-as.data.frame(tapply(data$DependentVariable.j,data[[IV]],mean))
> out$IV<-as.factor(as.numeric(row.names(out)))
> names(out)[1]<-"j"
> out2<-as.data.frame(tapply(data$DependentVariable,data[[IV]],mean))
> out<-cbind(out,out2)
> names(out)[3]<-"rf"
> par.settings=trellis.par.set(superpose.line
> list(col=c(PrimaryColors[4],SecondaryColors[4]),lwd =
> 2,lty=c(1,3)),
superpose.symbol = > list(cex = 1.5, pch =
> c(1,3),
lty=c(1,3),col=c(PrimaryColors[4],SecondaryColors[4])),
> reference.line = list(col =
> "gray", lty ="dotted"))
> plot<-dotplot(c(out$j,out$rf)~rep(out$IV,2),
> groups=rep(c("Method1","Method1"), each=nrow(out)),
> type="b",
> scales=list(x=list(cex=1.3),y=list(cex=1.3)),
auto.key = > list(space = "top", points = TRUE, lines = TRUE,cex=1.3),
> ylim=c(0,5),
> xlab=list(conditions.long[i],cex=1.2,font=2),
> ylab=list("Dependent Variable",cex=1.2,font=2),
> cex.lab=1.5,
panel = > function(y,x,...) {
> panel.grid(h = -1, v = -1)
> panel.xyplot(x, y, ...)
> ltext(x, y, labels=round(y,2),
> cex=1.3,col="black",font=1,pos=3)
> })
print(plot)
> dev.off()
}
--
Dimitri Liakhovitski
Ninah Consulting
> target="_blank"
> href="http://www.ninah.com">www.ninah.com
______________________________________________
> ymailto="mailto:R-help at r-project.org"
> href="mailto:R-help at r-project.org">R-help at r-project.org
mailing list
> href="https://stat.ethz.ch/mailman/listinfo/r-help" target=_blank
> >https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting > guide http://www.R-project.org/posting-guide.html
and provide commented, > minimal, self-contained, reproducible code.