colAny: Column and row-wise Any

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/Any.R

Description

Column and row-wise Any/All of a matrix.

Usage

1
2
3
4

Arguments

x

A logical matrix with the data.

parallel

Do you want the computations to take place in parallel? The default value is FALSE.

Details

The functions is written in C++ in order to be as fast as possible.

Value

A vector where item "i" is true if found Any/All true in column/row "i". Otherwise false.

Author(s)

R implementation and documentation: Manos Papadakis <papadakm95@gmail.com>.

See Also

Median, colMedians, colMeans (buit-in R function)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x <- matrix(as.logical(rbinom(100*100,1,0.5)),100,100)
system.time( a<-colAny(x) )
system.time( b<-apply(x,2,any) )
all.equal(a,b)

system.time( a<-rowAny(x) )
system.time( b<-apply(x,1,any) )
all.equal(a,b)

system.time( a<-colAll(x) )
system.time( b<-apply(x,2,all) )
all.equal(a,b)

a<-b<-x<-NULL

Example output

Loading required package: Rcpp
Loading required package: RcppZiggurat
   user  system elapsed 
  0.000   0.001   0.017 
   user  system elapsed 
  0.000   0.000   0.001 
[1] TRUE
   user  system elapsed 
      0       0       0 
   user  system elapsed 
  0.001   0.000   0.001 
[1] TRUE
   user  system elapsed 
      0       0       0 
   user  system elapsed 
  0.000   0.000   0.001 
[1] TRUE

Rfast documentation built on May 18, 2021, 1:07 a.m.