Anthony Darrouzet-Nardi
2004-Jun-02 20:26 UTC
[R] Using postscript() in a script that is source()ed
I have a script that draws 9 graphics which I would like to run by source()ing the file. In the script I make objects that contain each of the graphics (all lattice objects or functions that contain lattice functions). Then at the end of the script, I have a section which prints them to separate eps files like this: postscript(file = "dryoutcover.eps", height = 5, width = 7, horizontal = FALSE, onefile = FALSE, paper = "special") dryoutcover.plot # this is an object created by xyplot and it's one of the ones that doesn't print. dev.off() When I run the script using source(), only a couple of the graphics are drawn in the eps files. For the rest of them, there are blank eps files. The script works properly (the 9 eps files all have graphics in them) when I cut and paste the contents of it into R. It also works properly if I use source(..., verbose = T) giving output such as:>>>> eval(expression_nr. 82 )================> postscript(file = "dryoutcover.eps", height = 5, width = 7,horizontal = FALSE, onefile = FALSE, paper = "special") curr.fun: symbol postscript .. after 'expression(postscript(file = "dryoutcover.eps", height = 5, width = 7, '' horizontal = FALSE, onefile = FALSE, paper = "special"))'>>>> eval(expression_nr. 83 )================> dryoutcover.plot.. after 'expression(dryoutcover.plot)'>>>> eval(expression_nr. 84 )================> dev.off()curr.fun: symbol dev.off quartz 2 .. after 'expression(dev.off())' How can I get the non-verbose source() of my script to work? Anthony R 1.9.0 Mac OS 10.3.3
On Wed, 2 Jun 2004, Anthony Darrouzet-Nardi wrote:> I have a script that draws 9 graphics which I would like to run by > source()ing the file. In the script I make objects that contain each > of the graphics (all lattice objects or functions that contain > lattice functions). Then at the end of the script, I have a section > which prints them to separate eps files like this:There isn't any print() command here, so the object isn't printed.> postscript(file = "dryoutcover.eps", height = 5, width = 7, > horizontal = FALSE, onefile = FALSE, paper = "special") > dryoutcover.plot # this is an object created by xyplot and it's one > of the ones that doesn't print. > dev.off() > > When I run the script using source(), only a couple of the graphics > are drawn in the eps files. For the rest of them, there are blank eps > files. ><SNIP>> How can I get the non-verbose source() of my script to work?Use print(). -thomas Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle