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

Support for logical input in rowCummaxs et al.? #215

Closed Henrik-P closed 2 years ago

Henrik-P commented 3 years ago

First, thanks a lot for an excellent package.

This issue is related to colCumprods() does not support logical input, which was implemented. I just noted some other functions which don't support logical input: rowCummaxs, rowCummins, colCummaxs, colCummins. It would be great if they also could handle a logical x.

m = matrix(c(TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE), nrow = 3, byrow = TRUE)
m
#       [,1]  [,2]  [,3]
# [1,]  TRUE FALSE FALSE
# [2,] FALSE  TRUE FALSE
# [3,] FALSE FALSE  TRUE

rowCummaxs(m)
# Error in rowCummaxs(m) : Argument 'x' cannot be logical.

rowCummins(m)
# Error in rowCummins(m) : Argument 'x' cannot be logical.

colCummaxs(m)
# Error in colCummaxs(m) : Argument 'x' cannot be logical.

colCummins(m)
# Error in colCummins(m) : Argument 'x' cannot be logical.
HenrikBengtsson commented 2 years ago

I've just added support for this in the develop branch.