[R] plotmath: unexpected SPECIAL
Sarah Goslee
sarah.goslee at gmail.com
Thu Jun 23 03:10:40 CEST 2011
Dennis,
Thanks. That makes sense, but I don't think it's clearly documented.
The default assumption that I and at least some others in this
discussion made is that everything in the list of plotmath features in
the helpfile works the same way, since they're all in the same list.
And if for some of them you need paste, then you must for all. The
examples weren't much help in that regard.
I think there are reasons that plotmath confuses so many.
Sarah
On Wed, Jun 22, 2011 at 9:03 PM, Dennis Murphy <djmuser at gmail.com> wrote:
> Hi:
>
> From the plotmath help page:
>
> x %->% y x right-arrow y
>
> so this is behaving like a binary operator. There happen to be several
> of these in plotmath
>
> On Wed, Jun 22, 2011 at 5:49 PM, Sarah Goslee <sarah.goslee at gmail.com> wrote:
>> Interesting. I don't know the explanation, but look at this:
>> # works
>> plot(1:10, 1:10, xlab=expression(a %->% b))
>> # doesn't work
>> plot(1:10, 1:10, xlab=expression(%->%))
>
> Because there are no operands. This behavior can be replicated from
> the command line:
>
>> 10 %/% 2
> [1] 5
>> %/%
> Error: unexpected SPECIAL in "%/%"
>
> I think this explains the rest of the non-working examples as well,
> since you wouldn't do such things with binary operators.
>
>>
>> # works
>> plot(1:10, 1:10, xlab=expression(paste("something" %->% "else")))
>> # doesn't work
>> plot(1:10, 1:10, xlab=expression(paste("something", %->%, "else")))
>>
>> The "doesn't work" examples give the same error you report:
>> Error: unexpected SPECIAL in "plot(1:10, 1:10, xlab=expression(%->%"
>>
>> And then there's:
>> # doesn't work, as expected
>> plot(1:10, 1:10, xlab=expression(paste("something" phi "else")))
>
> phi is not an operator...
>
>> # works
>> plot(1:10, 1:10, xlab=expression(paste("something", phi, "else")))
>>
>> # works
>> plot(1:10, 1:10, xlab=expression(paste("something" %==% "else")))
>> # doesn't work
>> plot(1:10, 1:10, xlab=expression(paste("something", %==%, "else")))
>>
>> So it seems that when using an expression element bracketed by percent
>> signs, the commas in paste cause an error, even though they are
>> otherwise necessary. Hm.
>>
>> This is on a clean R 2.11 session on linux (I know, but that's the
>> latest version in the UNR repository, and I don't use R enough on this
>> netbook to install a non-repo version). I can try again tomorrow on an
>> up-to-date system.
>>
>> Sarah
>> - Hide quoted text -
>>
>>
>> On Wed, Jun 22, 2011 at 8:10 PM, Bryan Hanson <hanson at depauw.edu> wrote:
>>> Hello R Masters and the Rest of Us:
>>>
>>> The first of these works fine, the 2nd is accepted but too literal (the
>>> "%->%" is shown in the plot label and in the wrong position). The 3rd
>>> throws and error due to "unexpected SPECIAL". Would someone recommend a way
>>> to format this? I want the two phrases connected by a right arrow.
>>>
>>> TIA, these things always elude me. Bryan
>>
More information about the R-help
mailing list