Column and row-wise Any/All | R Documentation |
Column and row-wise Any/All of a matrix.
colAny(x)
rowAny(x)
colAll(x, parallel = FALSE, cores = 0)
rowAll(x, parallel = FALSE, cores = 0)
x |
A logical matrix with the data. |
parallel |
Do you want the computations to take place in parallel? The default value is FALSE. |
cores |
Number of cores to use for parallelism. Valid only when argument parallel is set to TRUE. Default value is 0 and it means the maximum supported cores. |
The functions is written in C++ in order to be as fast as possible.
A vector where item "i" is true if found Any/All true in column/row "i". Otherwise false.
R implementation and documentation: Manos Papadakis <papadakm95@gmail.com>.
Median, colMedians, colMeans (buit-in R function)
x <- matrix(as.logical(rbinom(100*100,1,0.5)),100,100)
a<-colAny(x)
#b<-apply(x,2,any)
#all.equal(a,b)
a<-rowAny(x)
#b<-apply(x,1,any)
#all.equal(a,b)
a<-colAll(x)
#b<-apply(x,2,all)
#all.equal(a,b)
a<-b<-x<-NULL
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.