[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



vor <- function(v) {
  ans <- v[1]
  if (length(v) > 1)
    for (i in 2:length(v))
      ans <- ans | v[i]

More information about the R-help mailing list