Skip to content

subscript with comma

7 messages · Uwe Ligges, David Winsemius, Nordlund, Dan (DSHS/RDA) +2 more

#
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?

Thanks in advance!


--
View this message in context: http://r.789695.n4.nabble.com/subscript-with-comma-tp4261579p4261579.html
Sent from the R help mailing list archive at Nabble.com.
#
On 04.01.2012 16:12, suse wrote:
?plotmath suggests to use a comma separated list as in:

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

Uwe Ligges
#
Thank you! It works now. 
But I still don't understand, how all these expressions, "", paste, group,
eval... have to be used together.  (For example, I first tried
expression(sm[w,grass]) but it didn't work, and I couldn't find, why (and
when) commas are interpreted here differently). So: Is there somewhere an
introduction (rather than examples) to this? Books, documents etc.

--
View this message in context: http://r.789695.n4.nabble.com/subscript-with-comma-tp4261579p4261931.html
Sent from the R help mailing list archive at Nabble.com.
#
On Jan 4, 2012, at 10:51 AM, Uwe Ligges wrote:

            
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]))
The other approach that succeeds it just to use a quoted comma  
connected by valid separators.

plot(1, main=expression(sm[w*","~grass]))
#
I haven't followed this whole thread and may have missed some requirement, but what about just using the text string that you want in the subscript?  E.g.

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


Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
#
On 12-01-04 11:41 AM, suse wrote:
You could try the reference from the ?plotmath page, but I don't think 
it is a tutorial, which seems to be what you want.

Basically the examples are how to do it.  Learn what expressions are 
like in R, then put together the pieces from demo(plotmath) by building 
expressions containing those pieces.

I don't see anything like sm[w,grass] in the demos, so I would just try 
it to see what happens:  and as you found, it doesn't work.

But there is an example with commas (list(x,y,z)) and an example with 
subscript (x[i]), so you should be able to guess that sm[list(w,grass)] 
would work, and it does!

Duncan Murdoch
#
David Winsemius wrote
Thanks, this helps.
I guess my problem was that I thought that the problem with the comma
occurred because of the [] around. I didn't think that comma itself was the
problem.

--
View this message in context: http://r.789695.n4.nabble.com/subscript-with-comma-tp4261579p4265308.html
Sent from the R help mailing list archive at Nabble.com.