[R] Using postscript() in a script that is source()ed

Anthony Darrouzet-Nardi anthony at darrouzet-nardi.net
Wed Jun 2 22:26:48 CEST 2004


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




More information about the R-help mailing list