R/sum_by.R

Defines functions sum_by

Documented in sum_by

sum_by <- function(x, by) {
    mm <- as(factor(by, levels=unique(by)), "sparseMatrix")
    cbind(x=as.numeric(mm %*% x), by=rowSums(mm))
}

Try the mefa4 package in your browser

Any scripts or data that you put into this service are public.

mefa4 documentation built on Sept. 12, 2022, 5:05 p.m.