[R] percentage sign in expression
e-letter
inpost at gmail.com
Thu Aug 26 09:17:39 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! ;-)
>
No, following previous advice it would be preferable to add the
following (or similar) to the documentation:
'syntax' 'meaning'
...
'%' %
...
>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?
>
I did not read any instruction that it was code to apply! Anyway,
below is the result:
> 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
Error: syntax error, unexpected '}' in:
"
"
> + if (sign == -1) r <- c(32:126, 160:255)
Error in sign == -1 : comparison (1) is possible only for atomic and list types
> + par(pty="s")
Error in +par(pty = "s") : invalid argument to unary operator
> + plot(c(-1,16), c(-1,16), type="n", xlab="", ylab="",
+ + xaxs="i", yaxs="i")
Error: syntax error, unexpected EQ_ASSIGN, expecting ',' in "+
plot(c(-1,16), c(-1,16), type="n", xlab="", ylab="","
> + grid(17, 17, lty=1)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) :
plot.new has not been called yet
> + for(i in r) try(points(i%%16, i%/%16, pch=sign*i, font=font,...))
Error: object "r" not found
> + }
Error: syntax error, unexpected '}' in "+ }"
> TestChars(font=5)
Error: could not find function "TestChars"
More information about the R-help
mailing list