[R] all(logical(0)) and any(logical(0))

Liaw, Andy andy_liaw at merck.com
Thu Apr 15 17:02:04 CEST 2004


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?

Andy

>




More information about the R-help mailing list