[R] blockwise sums

Vicente Canto Casasola vicented.canto.ext at juntadeandalucia.es
Wed Sep 1 13:03:31 CEST 2004

Hi, all!!

 From the help page for 'aggregate':
     Splits the data into subsets, computes summary statistics for
     each, and returns the result in a convenient form.

So here's the solution I found to this problem:

blocksums <- function(x,n)
temp <- 1:length(x)-1
temp <- list((temp%/%n)+1)

For instance:
[1]  6 15 24 10

Hope this helps!!

More information about the R-help mailing list