[R] percentage sign in expression

Gavin Simpson gavin.simpson at ucl.ac.uk
Wed Aug 25 11:47:05 CEST 2010


On Wed, 2010-08-25 at 09:32 +0100, e-letter wrote:
> On 24/08/2010, David Winsemius <dwinsemius at comcast.net> wrote:
> >
> > On Aug 24, 2010, at 9:37 AM, e-letter wrote:
> >
> >> Readers,
> >>
> >> According to the documentation for the function 'plotmath' there is no
> >> apparent possibility to add the percent sign (%) to a plot function,
> >
> > Where did you see an assertion made???
> >
> Within R I entered the command:
> 
> ?plotmath

Surely you don't expect the R help pages to document everything that
*isn't* possible with a given function? They'd be infinitely long! ;-)

What you meant to say was, "?plotmath doesn't show me how to add a %
symbol to a plot. How do I do it?"

> Also accessed using:
> 
> help.start(browser="opera")
> 
> Navigating the web browser page:
> 
> packages
> packages in /usr/lib/R/library
> grdevices
> plotmath
> 
> In the list headed 'syntax' and 'meaning' within the section 'details'.
> 
<snip />
> >  > TestChars <- function(sign=1, font=1, ...)
> > + {
> > +    if(font == 5) { sign <- 1; r <- c(32:126, 160:254)
> > +    } else if (l10n_info()$MBCS) r <- 32:126 else r <- 32:255
> > +    if (sign == -1) r <- c(32:126, 160:255)
> > +    par(pty="s")
> > +    plot(c(-1,16), c(-1,16), type="n", xlab="", ylab="",
> > +         xaxs="i", yaxs="i")
> > +    grid(17, 17, lty=1)
> > +    for(i in r) try(points(i%%16, i%/%16, pch=sign*i, font=font,...))
> > + }
> >  > TestChars(font=5)
> >
> > Notice that the "%" sign is three characters to the right (i.e.
> > higher) of the "forall" symbol that is produced by the example code
> 
> I can't see 'forall' in the code above.

You need to run it in R. Then you will see a plot of the glyphs
available in the symbol font. 'forall' is a mathematical symbol:

http://en.wikipedia.org/wiki/Table_of_mathematical_symbols

> > they offer. (The numbering proceeds from bottom up which confused me
> > at first.)
> >
> What numbering?

The numbering of the glyphs so you can use the number to draw the symbol
you want. They are on the plot. You did run the code provided by David?

Anyway, is there a problem with this:

plot(1:10, xlab = expression(foo == 15*"%"))

That way you don't need to worry about finding the right glyph.

HTH

G

> The documentation makes reference to the command:
> 
> demo(plotmath)
> 
> I applied this command and could not see an instruction to produce the
> percent (%) symbol.
> 
> ______________________________________________
> 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.

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list