[R] subscript with comma

David Winsemius dwinsemius at comcast.net
Wed Jan 4 18:53:27 CET 2012


On Jan 4, 2012, at 10:51 AM, Uwe Ligges wrote:

>
>
> On 04.01.2012 16:12, suse wrote:
>> Hi,
>>
>> I want to write a word with subscript in a graph. Unfortunately, the
>> subscript contains a comma, so all my trials didn't work and I  
>> didn't find
>> how to do it.
>> I want to write "sm" as normal text and "w,grass" in the subscript.  
>> Can
>> anybody help me?
>>
>> And a more general question: I read the help to "plotmath", but I  
>> still
>> didn't understand, how it works. Is there a good documentation,  
>> book,...
>> which explains all this stuff?

I've wondered about that, too. Murrell's text, R Graphics, doesn't  
even have plotmath in its function list or Index. The insight that  
allowed me to get a significantly higher frequency of success was   
realizing that the correct separators between separate expressions  
were "*" and "~" rather than <space> or <comma>. Inside an expression  
a comma will signal a new expression element. A space without a  
plotmath operator intervening just throws an error

 > plot(1, main=expression(sm[w grass]))
Error: unexpected symbol in "plot(1, main=expression(sm[w grass"

My suggestion is to search the archive for answers from Ligges,  
Dalgaard, Lumley and Grothendeick that involve "expression" or  
plotmath. (Apologies to any other plotmath-meisters). I still get  
surprises such as with these:

plot(1, main=expression(sm[w|grass]))

plot(1, main=expression(sm[w%|%grass]))


>
> ?plotmath suggests to use a comma separated list as in:
>
> plot(1, main=expression(sm[list(w,grass)]))
>

The other approach that succeeds it just to use a quoted comma  
connected by valid separators.

plot(1, main=expression(sm[w*","~grass]))

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list