A hack to speed up tapply(x, group, sum) for the special case where
x is sorted by group.
Usage
tapplysum.fast(x, groups)
Value
Vector containing the group sums of x.
Arguments
x
A numeric vector.
groups
A grouping factor.
Author
C. H. Jackson <chris.jackson@mrc-bsu.cam.ac.uk>
Details
Works by computing the cumulative sum of x and taking the difference
at the indices where the groups change. Standard tapply can
be slow when there are a large number of groups, due to the overhead
of factor manipulation.