[R] lattice.device in loop

Sundar Dorai-Raj sundar.dorai-raj at PDF.COM
Tue Jul 27 18:41:26 CEST 2004



Matt Pocernich wrote:
> Hi,
> 
> I am having problems creating a pdf file of a lattice graph.  Things work
> fine for a single image, but I am having trouble using the commands in a
> loop.  To illustrate by example
> 
> This works with both ps and pdf files.
> 
> dat = list(x= 1:10, y = 1:10)
>  trellis.device(postscript, file = "/d1/pocernic/test.ps")
>     xyplot(y~x, data = dat)
> dev.off()
> 
> 
> This does not.   It produces a very small, non working output file.
> 
> for(i in 1:1){
>  trellis.device(postscript, file = "/d1/pocernic/test.ps")
> 
>     xyplot(y~x, data = dat)
> dev.off()
>  }
> 
> Really, I would like something like this to produce a large, appended file
> made from different large datasets.  This doesn't work either.
> 
> trellis.device(postscript, file = "/d1/pocernic/test.ps", onefile = TRUE)
> for(i in 1:5){
>     xyplot(y~x, data = dat)
>  }
> 
> dev.off()
> 
> Any thoughts would be welcomed.
> 
> 
> 
> Matt Pocernich
> NCAR - Research Applications Program
> 303-497-8312
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

This is a FAQ 7.24.

http://cran.r-project.org/doc/FAQ/R-FAQ.htm

--sundar




More information about the R-help mailing list