[R] or of a logical vector

Ben Wittner bwittner at jimmy.harvard.edu
Thu Aug 5 18:38:01 CEST 2004


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
}




More information about the R-help mailing list