"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