[R] percentage sign in expression

David Winsemius dwinsemius at comcast.net
Wed Aug 25 15:48:35 CEST 2010


On Aug 25, 2010, at 4:32 AM, 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
>
> 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'.
>
>>> e.g.
>>>
>>> plot(a[,1]~b[,2],ylab=expression(x~%),xlab=expression(z))
>>
>>
>>>
>>> How to achieve this please?
>>
>> Read the plotmath helo page more carefully. The section immediatedly
>> below the plotmath expressions points you to the use of the symbol()
>> expression-function and to the points help page where generation of
>> the available glyphs proceeds according to the advice on  
>> help(plotmath):
>>
> In my system the paragraph immediately after the list of features
> (i.e. 'syntax','meaning') describes a note to TeX users. I cannot see
> reference to 'symbol()'.

It's possible that my help page is different than yours. Right after  
the syntax/meaning description on mine (which is a Mac OSX system) is  
a paragraph:

"The symbol font uses Adobe Symbol encoding so, for example, a lower  
case mu can be obtained either by the special symbol mu or by  
symbol("m"). This provides access to symbols that have no special  
symbol name, for example, the universal, or forall, symbol is  
symbol("\042"). To see what symbols are available in this way  
useTestChars(font=5) as given in the examples for points: some are  
only available on some devices."

(In this case I would be surprised if the help pages were different  
because this makes a cross-reference to the examples in points.  I am  
not surprised about cross-platform differences in descriptions of  
graphical devices  and would have included a caveat if I were  
corresponding on rhelp about such. I suppose the font issues could be  
platform specific so if you want to correct me on this point, I will  
try to file it away. I did, however, give you the code needed to to  
display Symbols and it sounds further on that it succeeded)

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

Gavin has already explained why you did not. The upside-down A (==  
"universal" or "forall") was a useful reference point in the indexing,  
since it is only 3 glyphs away for the "%" symbol.

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

Actually I did not see any numbering either, which was why I remained  
confused about the location of the "%" symbol for several minutes.  
Perhaps I should have used the term "indexing".


>
> The documentation makes reference to the command:
>
> demo(plotmath)
>
> I applied this command and could not see an instruction to produce the
> percent (%) symbol.

I don't think I suggested it would.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list