[R] 'postscript' command within a function

Edoardo Airoldi eairoldi at stat.cmu.edu
Mon Jul 7 04:11:55 CEST 2003


hello all,
  I am trying to print a ps file as part of a function as in:

func <- function (..., filename="temp.ps") {
	# some stuff
	[...]

     # plot
     eval( cat("postscript(\"",filename,"\")\n", sep="") )
     plot(...)
     abline(...)
     dev.off()

	# more stuff
	[...]
}

but it does not work.  Nor it does with 'paste' instead of 'cat'.  In 
order to make it work I have to call:
 > postscript("temp.ps")
 > func(...)
 > dev.off()

I am wondering why is that?  How can I make my call to postscript within a 
function sort of 'global' ??
thanks
Edo




More information about the R-help mailing list