[R] cannot create postscript files with trellis graphics inside a function

Faheem Mitha faheem at email.unc.edu
Mon Apr 14 05:13:42 CEST 2003


Dear People,

If I define

foo <-function()
{
  x <- rnorm(500)
  trellis.device(postscript, file="plot.ps")
  densityplot(~x)
  dev.off()
 }

and call foo() then plot.ps is just a blank plot. However, if I extract
the lines inside foo and run them, ie.

x <- rnorm(500)
trellis.device(postscript, file="plot.ps")
densityplot(~x)
dev.off()

then plot.ps is created without problems. The former method worked with
the regular postscript() device, which I used to use all the time inside
functions.

I've never used lattice/trellis graphics before. Is this a bug or am I
doing something wrong?

                                                  Faheem.



More information about the R-help mailing list