I had such good luck with my previous question to r-help, (a few minutes
ago) that I thought I would try again with the following query:

Suppose I have

    xNm <- "gamma"

I would like to be able to do

    plot(1:10,xlab = <something involving xNm">)

and get the x axis label to be the Greek letter gamma
(rather than the literal text string "gamma").

Is this possible?  I've messed around with substitute()
and bquote() and got nowhere.

Then, just before clicking on "Send", I had one more thimk, and blow
me down, I got something that worked:

plot(1:10,xlab=eval(expression(parse(text=xNm))))

This is another counter example to my colleague Thomas Lumley's dictum
expressed in fortune("parse").  :-)

I had to try several permutations of "eval" and "expression" and "parse",
but I finally found that the permutation presented above does what I want.
(Clearly I have no real idea what I'm doing, just hammering and hoping,
but it's amazing how far hammer and hope will get you sometimes with R!)

Just thought I'd post this in case it might be helpful to others. Also to see
if anyone can tell me a better/slicker/sexier way to get to the same result.

    cheers,

            Rolf Turner

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to