Skip to content
Prev 295065 / 398506 Next

Names of Greek letters stored as character strings; plotmath.

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

Thread (18 messages)

Rolf Turner Names of Greek letters stored as character strings; plotmath. May 18 Gabor Grothendieck Names of Greek letters stored as character strings; plotmath. May 19 Bert Gunter Names of Greek letters stored as character strings; plotmath. May 19 Bert Gunter Names of Greek letters stored as character strings; plotmath. May 19 William Dunlap Names of Greek letters stored as character strings; plotmath. May 19 Paul Johnson Names of Greek letters stored as character strings; plotmath. May 19 Gabor Grothendieck Names of Greek letters stored as character strings; plotmath. May 19 William Dunlap Names of Greek letters stored as character strings; plotmath. May 19 Rolf Turner Names of Greek letters stored as character strings; plotmath. May 19 Robert Baer Names of Greek letters stored as character strings; plotmath. May 20 Rolf Turner Names of Greek letters stored as character strings; plotmath. May 20 Duncan Murdoch Names of Greek letters stored as character strings; plotmath. May 20 Bert Gunter Names of Greek letters stored as character strings; plotmath. May 20 Joshua Wiley Names of Greek letters stored as character strings; plotmath. May 20 Duncan Murdoch Names of Greek letters stored as character strings; plotmath. May 20 Peter Dalgaard Names of Greek letters stored as character strings; plotmath. May 21 William Dunlap Names of Greek letters stored as character strings; plotmath. May 21 Bert Gunter Names of Greek letters stored as character strings; plotmath. May 21