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

From: Uwe Ligges <ligges_at_statistik.tu-dortmund.de>
Date: Tue, 10 May 2011 11:57:47 +0200

On 10.05.2011 03:36, John S wrote:
> 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")}

You may not be able to allocate space for this huge tiffs (at least I am not able to do so under Windows).

> 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

Your forgot parentheses after dev.off.

Uwe Ligges

> }
>
> 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.



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 - 10:04:27 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 - 14:00: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