On Mar 1, 2012, at 2:40 PM, Dennis Fisher wrote:

R 2.14.0
OS X

Marc's proposed solution (appearing at the end of this email) is perfect -- thanks so much
However, some questions remain:

1.  The following works:
        plot(1, type="n")
        text(1, 1, expression(symbol("\342")))

but this does not work (TEXT appears in a symbol font)
        plot(1, type="n")
        TEXT    <- "\342"
        text(1, 1, expression(symbol(TEXT)))

?substitute
  text(1, 1, substitute( symbol(TEXT), list(TEXT=TEXT) )  )

?bquote

text(1, 1, bquote( symbol( .(TEXT )  ) ) )


nor does this work (it yields: Error: could not find function "symbol")
        plot(1, type="n")
        TEXT    <- symbol("\342")
        text(1, 1, expression(TEXT))
Clearly, I do not understand the subtleties of plotmath.

expression() does not evaluate names within its arguments. Similar issues arise with the use of "$" as a function. That's why it's often the answer to programming questions that one should use obj[[colnam]] than it is to use obj$colnam. "[[" does evaluate its argument.

 Could someone explain?

Try instead:

plot(1, type="n")
        TEXT    <- expression(symbol("\342"))
        text(1, 1, TEXT)

If you want to build up from character-type components then you can use paste and wrap the whole think in as.expression(). bquote() is much better, though.

--
David.


2. How would one learn that \342 corresponds to the copyright sign in the symbol font? (i.e., is there a list of all possible characters)



Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com

On Feb 29, 2012, at 6:55 PM, Marc Schwartz wrote:

Dennis,

Depending upon some additional fine tuning, here is a generic example:

plot(1)
legend("topright", pch = 1, legend = expression(SOMETEXT ^ symbol("\342")))


See ?plotmath for more information. The above works on my MBP running Lion.

HTH,

Marc Schwartz



        [[alternative HTML version deleted]]

______________________________________________
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.

David Winsemius, MD
West Hartford, CT

______________________________________________
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