Many thanks to Baptiste Auguie (off list), Bill Dunlap, Bert Gunter, Gabor Grothendieck,
and Paul Johnson for their interesting and informative responses to my post.

The main item to note is that I was piling on unnecessary baggage by using

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

Just the "parse()" bit is all that is necessary:

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

accomplishes the same task and is much simpler.

I have taken note of, and stored away for future reference, the suggestions
for the use of substitute, bquote, quote, as.name and as.symbol. I am particularly
grateful for Bert Gunter's explanation of why

    xNm <- "gamma"
    plot(1:10,xlab= bquote(.(xNm))

yields the string "gamma" rather than the symbol consisting of the Greek letter
gamma.

I am also very grateful for Bill Dunlap's example of how things can go wrong
with parse.

I sympathise with Paul Johnson's complaint that there are often too many ways
to accomplish the same task and that sometimes some ways work in some
contexts but not in others. However it seems to me that we're just stuck with
this.  There is no way to make a perfect programming language --- perfection
just doesn't exist.  From my POV, R comes as close to the ideal as one can
reasonably expect.  The fact that R is constantly growing and developing
contributes to the fact that ways to accomplish the same task proliferate,
but its growth and development are such an asset that we must (cheerfully!)
just live with the attendant drawbacks.

Again, thanks to all.

    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