[R] 'all' inconsistent?

Elizabeth Purdom epurdom at stanford.edu
Mon Jan 30 06:43:04 CET 2006

I came across the following behavior, which seems illogical to me. I don't 
know if it is a bug or if I'm missing something:

 > all(logical(0))
[1] TRUE
 > any(logical(0))
 > isTRUE(logical(0))

This actually came up in practice when I did something like
 > all( names(x) %in% vec )
as an error-handling, and I was hoping that it would work regardless of 
whether x had names or not. I can clearly work around it, but it seemed 
like strange behavior to me.
Elizabeth Purdom
R 2.2.1, Windows XP

More information about the R-help mailing list