I suspect that some people still might not have caught why
the behavior is a good thing.

We want

any(c(A, B))

to give the same answer as

any(A) || any(B)

This should be the behavior even if all of the elements are
in one of the vectors.

This actually is useful in coding, though I can't think of any
specific instances at the moment.

Patrick Burns

Burns Statistics
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

Douglas Bates wrote:

"Liaw, Andy" <[EMAIL PROTECTED]> writes:



I wrote:



I was bitten by the behavior of all() when given logical(0): It is TRUE!
(And any(logical(0)) is FALSE.) Wouldn't it be better to return logical(0)
in both cases?


I guess the behavior is consistent with:



prod(numeric(0))


[1] 1


sum(numeric(0))


[1] 0

but why?



The operation applied to a zero-length vector returns the identity element of the operator. The identity element of * is 1, of + is 0, of & is TRUE and of | is FALSE.

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html





______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to