HenrikBengtsson / matrixStats

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

Idea: grouped calculations #224

Closed mayer79 closed 1 year ago

mayer79 commented 1 year ago

Hello HenRik

In base R, there is this wonderful function rowsum(). It calculates sums of all columns in a matrix, grouped by the unique values of a second argument. It is astonishingly fast. Have you ever thought of implementing something like rowsum, but for other statistics (mean, median, weighted mean, variance) etc.?

?

mayer79 commented 1 year ago

Just detected the "collapse" package from some (other) big names with this functionality (sum, mean, sd, var, count, cumsum, quantile, ...) with or without weights.

Will close this issue.