> I guess you would want eval(MYPLOT) there?
>
> But the function above works if you say
>   plot.both(myplot = expression(plot(x)), filename = "foo")
> and that is what I said above: set myplot = expression(plot(x)).
> Z

My syntax in the example was a little bit messed, sorry for that.

However Gabor Grothendieck's reply has brought me to the solution. The 
following function does the job right:

print.both <- function(myplot, filename){
     pdf(file=paste(filename, ".pdf", sep=""))
     postscript(file=paste(filename, ".eps", sep=""))
    dev.control(displaylist="enable")
    myplot
    dev.copy(which=dev.next())
    graphics.off()
}

The dev.control(displaylist="enable") is necessary here because only then R 
does record the plot and dev.copy can be used.

So, thank you all for your help.

Ronny

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to