HenrikBengtsson / matrixStats

R package: Methods that Apply to Rows and Columns of Matrices (and to Vectors)
https://cran.r-project.org/package=matrixStats
203 stars 33 forks source link

WISH: col/rowCounts but for inequalities #134

Open PeteHaitch opened 6 years ago

PeteHaitch commented 6 years ago

We have rowCounts(x, value = 10) as an efficient version of rowSums(x == 10). It'd be neat to have similarly efficient versions of rowSums(x > 10), rowSums(x >= 10), rowSums(x <= 10), rowSums(x < 10), and rowSums(x != 10).

Conceptually, it could be it's own function or it might add an argument to col/rowCounts(), something like:

rowCounts( x, rows = NULL, cols = NULL, value = TRUE, na.rm = FALSE, 
           dim. = dim(x), comparison = c("==", "<", "<=", ">", ">=", "!="), ...)
HenrikBengtsson commented 6 years ago

Yes, this would be neat. It's related https://github.com/HenrikBengtsson/matrixStats/issues/51