From: Felipe Csaszar <fcsaszar_at_gmail.com>

Date: Mon 15 Aug 2005 - 05:06:45 EST

R-help@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 Received on Mon Aug 15 05:13:51 2005

Date: Mon 15 Aug 2005 - 05:06:45 EST

Thanks, it worked!

So the cute trick was the call to *quote* inside the function call.

Thanks again,

Felipe

On 8/14/05, Gabor Grothendieck <ggrothendieck@gmail.com> wrote:

> On 8/14/05, Felipe Csaszar <fcsaszar@gmail.com> wrote:

*> > Hello everyone,
**> >
**> > I want to define a function that receives the name of two variables
**> > (may include Greek letters and subscripts) and uses them into the
**> > title of a plot.
**> >
**> > My best attempt is the following:
**> > myplot <- function(var1, var2) {
**> > v=paste(var1,"==1 & ",var2,"==2");
**> > plot(1:10, main=parse(,,v))
**> > }
**> >
**> > But when I call it with something like myplot("Q[i]", "Delta[j]") I
**> > get "&(Q_i=1,Delta_j=2)" as title when I want to get "Q_i=1 &
**> > Delta_j=2".
**> >
**> > Is there any solution within R? (I don't want to use psfrag and Latex
**> > to post-process the plot)
**> >
**> > Why R does not have support for full Latex expressions? (as Matlab
**> > f.ex.). IMHO plotmath is not good enough.
**> >
**>
**> Try this:
**>
**>
**> myplot <- function(var1, var2)
**> plot(1:10, main = bquote(.(var1) == 1 ~ "&" ~ .(var2) == 2))
**> myplot(quote(Q[i]), quote(Delta[j]))
**>
*

R-help@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 Received on Mon Aug 15 05:13:51 2005

*
This archive was generated by hypermail 2.1.8
: Sun 23 Oct 2005 - 15:19:35 EST
*