[R] pdf files in loops
Paul Hiemstra
p.hiemstra at geo.uu.nl
Thu Apr 1 11:11:05 CEST 2010
James Rome wrote:
> On 3/31/2010 10:01 PM, Berwin A Turlach wrote:
>
> G'day James,
>
> On Wed, 31 Mar 2010 21:44:31 -0400
> James Rome <jamesrome at gmail.com> wrote:
>
>
>
>> I need to make a bunch of PDF files of histograms.
>>
>>
> [...]
>
>
>> What am I doing wrong?
>>
>>
> http://cran.ms.unimelb.edu.au/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f
>
> HTH.
>
> Cheers,
>
> Berwin
>
> --------------------------
> I got it. Thanks. I forgot to assign the graph to a variable. :-(
>
> for( gate in gatelist) {
> outfile = paste("../", airport, "/", airport, "taxiHistogram", gate,
> ".pdf", sep="")
> pdf(file = outfile, width = 10, height=8, par(lwd=1))
> title=paste("Taxi time for Arrival Gate", gate, "by Runway at", airport)
> gdf = mdf[mdf$ArrivalGate == gate, ]
> gdf$tt= gdf$TaxiTime/60
> g = histogram(~(gdf$tt) | gdf$Runway, data=gdf, type="count",
> ylab="Count", breaks=20, main=title,
> xlab="taxi time (min)", par.strip.text=list(cex=0.7))
> print(g)
> dev.off()
> }
>
> works. Is there a way to make all the plots pages in one pdf file?
>
Hi,
Put the pdf() and the dev.off() outside the loop and the plots will be
on separate pages in the same pdf file.
pdf()
loop
dev.off()
cheers,
Paul
> Thanks,
> Jim
>
> ______________________________________________
> 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.
>
--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone: +3130 274 3113 Mon-Tue
Phone: +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul
More information about the R-help
mailing list