[R] 'all' inconsistent?

Gabor Grothendieck ggrothendieck at gmail.com
Mon Jan 30 07:55:36 CET 2006


I think the corresponding question was already discussed in
the context of sum and in terms of this question one wants:

all(x) && all(y) to equal all(c(x,y))

including the case where x or y has zero length.

On 1/30/06, Elizabeth Purdom <epurdom at stanford.edu> wrote:
> Hello,
> 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))
> [1] FALSE
>  > isTRUE(logical(0))
> [1] FALSE
>
> 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.
> Thanks,
> Elizabeth Purdom
> R 2.2.1, Windows XP
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list