[R] subscript with comma

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Wed Jan 4 19:23:29 CET 2012


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




More information about the R-help mailing list