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.
subscript with comma
7 messages · Uwe Ligges, David Winsemius, Nordlund, Dan (DSHS/RDA) +2 more
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?
?plotmath suggests to use a comma separated list as in: plot(1, main=expression(sm[list(w,grass)])) Uwe Ligges
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.
______________________________________________ R-help at 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.
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:
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
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- project.org] On Behalf Of David Winsemius Sent: Wednesday, January 04, 2012 9:53 AM To: Uwe Ligges Cc: r-help at r-project.org; suse Subject: Re: [R] subscript with comma 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
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:
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.
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
-- 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.
______________________________________________ R-help at 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 wrote
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
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.