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.?
Just detected the "collapse" package from some (other) big names with this functionality (sum, mean, sd, var, count, cumsum, quantile, ...) with or without weights.
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 likerowsum
, but for other statistics (mean, median, weighted mean, variance) etc.??