[R] are arithmetic comparison operators binary?
Wacek Kusnierczyk
Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Mon Feb 23 19:29:31 CET 2009
Martin Maechler wrote:
>>>>>> "WK" == Wacek Kusnierczyk <Waclaw.Marcin.Kusnierczyk at idi.ntnu.no>
>>>>>> on Mon, 23 Feb 2009 12:06:32 +0100 writes:
>>>>>>
>
> Thank you, Wacek,
> though .. "wrong mailing list"
>
apologies. i was actually asking for explanation, assuming that it
might be my misunderstanding, rather than reporting a bug.
> WK> the man page for relational operators (see, e.g., ?'<') says:
> WK> "
> WK> Binary operators which allow the comparison of values in atomic vectors.
>
> WK> Arguments:
>
> WK> x, y: atomic vectors, symbols, calls, or other objects for which
> WK> methods have been written.
> WK> "
>
> WK> it is somewhat surprizing that the following works:
>
> WK> '<'(1)
> WK> # logical(0)
>
> WK> '<'()
> WK> # logical(0)
>
> WK> '<'(1,2,3)
> WK> # TRUE
>
> a bit surprising (sic!), indeed, even for me.
> Thanks for your notice and report!
>
you're welcome.
shouldn't the tests have captured it? i think you should have a check
for every feature following from the docs. plus those undocumented, but
assumed by the developers.
> If you'd looked a bit in the sources, you'd seen that they
> really are supposed to be binary only.
>
it wouldn't be nonsensical to let them be of arbitrary arity (in a
well-documented manner), though it might confuse users.
> A very small change in the sources does accomplish this, passes
> the standard checks (and I cannot imagine reasonable code that
> would have relied on the more lenient behavior), so
> this will have changed in one of the next versions of R-devel.
>
thanks.
just a question (i haven't checked the sources, maybe i should): what
is it that happens when one of the operators is called with n = 0 or 1
argument? how does it come up with logical(0) rather than NA?
cheers,
vQ
More information about the R-help
mailing list