[R] lattice.device in loop

Matt Pocernich pocernic at rap.ucar.edu
Tue Jul 27 18:30:40 CEST 2004


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




More information about the R-help mailing list