[R] or of a logical vector

Liaw, Andy andy_liaw at merck.com
Thu Aug 5 20:41:54 CEST 2004


Is there anything wrong with sum(v) > 0?

Andy

> From: Ben Wittner
> 
> Is there some fast (built-in?) way to get the OR of all the 
> elements in a
> logical vector?
> 
> In other words, is there some fast (built-in) version of the 
> function vor
> below?
> 
> Thanks.
> 
> -Ben
> 
> vor <- function(v) {
>   ans <- v[1]
>   if (length(v) > 1)
>     for (i in 2:length(v))
>       ans <- ans | v[i]
>   ans
> }
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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
> 
>




More information about the R-help mailing list