unary !

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Mon, 5 Jan 1998 08:49:12 +0100

[spill over from  R-core]

>>>>> "TL" == Thomas Lumley <thomas@biostat.washington.edu> writes:

    TL> On Sun, 4 Jan 1998, Kurt Hornik wrote:
    >> Another thing I noticed when playing with chron is that apparently
    >> code like if (!(length(value)) works in S but not in R.  The error
    >> in R is unary ! is only defined for logical vectors
    >> I assume that this is a bug and not a feature (although the code in
    >> src/main/logic.c makes me wonder ...).

    TL> I complained about this more than a year ago and I thought we (or
    TL> in those days R+R) had decided it was a feature -- I just explained
    TL> to someone on r-help that it was one of the deliberate
    TL> incompatibilities that ! didn't work on numerics.

Yes, positively.  We've discussed this quite a bit, and
this was defined to be a feature long ago.

The proper (non C-hacker but normal-user readable) way  is to test for

	if(length(vector) == 0)

- Martin
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch