[R] or of a logical vector

Spencer Graves spencer.graves at pdf.com
Thu Aug 5 20:19:31 CEST 2004


?any

hope this helps.  spencer graves

Ben Wittner wrote:

>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