Hi Dennis,

There are some subtleties in the way that 'symbol' is handled in plotmath. 
There is no symbol() function, per se, though there is an as.symbol() function, 
which is used differently.

'symbol' as used in plotmath, is telling R to plot the character using a symbol 
font, which is the same as 'font = 5'.

If you look at some of the examples in ?plotmath and ?bquote, you can see that 
there is the use of the syntax:

  .(VarName)

where VarName is the name of a scalar that contains the value/character that is 
desired to be plotted.

Thus, to do the sort of thing you desire:

  TEXT <- "\342"

  plot(1, type = "n")
  text(1, 1, bquote(symbol(.(TEXT))))

or:

  plot(1, type = "n")
  text(1, 1, bquote(.(TEXT)), font = 5)

Also, with respect to a listing of the symbols, see the References section of 
?plotmath, which leads you to pages such as:

  http://www.stat.auckland.ac.nz/~paul/R/CM/AdobeSym.html

HTH,

Marc

On Mar 1, 2012, at 1: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)))
> 
> 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.  Could someone 
> explain?
> 
> 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.

Reply via email to