Skip to content
Prev 65628 / 398506 Next

function in order to plot the same graph to postscript and pdf

Use substitute() instead of expression(); choose to use either MYPLOT or
myplot because they are different variables; and use parentheses around
your function arguments instead of braces.

-----Original Message-----
From: Ronny Klein [mailto:ronny.klein at wiwi.uni-halle.de] 
Sent: Wednesday, March 09, 2005 12:22 PM
To: Achim Zeileis
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] function in order to plot the same graph to postscript
and pdf
I've followed your advice and changed my function to something like
this:

plot.both <- function{myplot, filename}{
     MYPLOT <- expression(myplot)
     pdf(file=paste(filename, ".pdf", sep=""))
     eval(myplot)
     dev.off()
     postscript(file=paste(filename, ".eps", sep=""))
     eval(myplot)
    dev.off()
 }

However the result is the same: the first one is actually printed but
the 
second plot is empty. 

Ronny

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