[R] blockwise sums
Gabor Grothendieck
ggrothendieck at myway.com
Tue Aug 31 15:13:57 CEST 2004
Lutz Prechelt <prechelt <at> pcpool.mi.fu-berlin.de> writes:
:
: I am looking for a function like
: my.blockwisesum(vector, n)
: that computes sums of disjoint subsequences of length n from vector
: and can work with vector lengths that are not a multiple of n.
:
: It should give me for instance
: my.blockwisesum(1:10, 3) == c(6, 15, 24, 10)
tapply(v, (seq(v)-1)%/%n, sum)
More information about the R-help
mailing list