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)

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to