Skip to content
Prev 164886 / 398503 Next

sliding window over a large vector

For this particular proble (counting), doesn't cumsum solve it
effectively and efficiently?

    vv <- cumsum(v)
    vv[n:length(vv)] - vv[1:(length(vv)-n+1]

Of course, this doesn't work for the general case of an arbitrary
sliding window function.

     -s
On 12/15/08, Chris Oldmeadow <c.oldmeadow at student.qut.edu.au> wrote: