[R] Saving multiple 3x3 TIFF graphics inside a loop

From: John S <john.smithr75_at_gmail.com>
Date: Mon, 09 May 2011 18:36:16 -0700


Dear Friends,

I have been trying to save multiple 3x3 (mfrow=c(3,3) graphics inside a loop using tiff figure format (not using PDF or savePlot functions) with no success. Could you please help?

Here is a simplified example code:

dat=data.frame (ID=rep(1:10,each=10),IDV=rep(seq(1:10),times=10))

dat$DV <- with(dat, 50+15*IDV)

dat=dat[order(dat$ID,dat$IDV),]

for(i in 1:10){

   dt1 = dat[dat$ID==i,]

   pagei=as.integer(ceiling(i/9))

   #This does not work

   if(i==1) {tiff(file=paste("Outfile",pagei,".tiff",sep="")

,width=17.15,height=17.15,units="cm", res=1200, pointsize=10,
compression = "lzw")}

  if(i==10) {tiff(file=paste("Outfile",pagei,".tiff",sep="")

,width=17.15,height=17.15,units="cm", res=1200, pointsize=10,
compression = "lzw")}

   par(mar=c(5,5,4,1),mfrow=c(3,3))

   plot(dt1[, "IDV"],dt1[, "DV"], type="n")

   lines(dt1[, "IDV"], dt1[, "DV"], type="b", col=1,lwd=3,pch=1)

   title(paste(i),col=8,cex=.8)

 if(i==9) dev.off ## close file

}

dev.off()

 The idea is to save 2 files with 3x3 layouts but I only get one subject in Outfile1.

OS: Windows 7 64 bits

R version 2.13.0

Many Thanks,

John

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
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. Received on Tue 10 May 2011 - 02:58:03 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 10 May 2011 - 10:20:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive