Skip to content
Prev 327890 / 398498 Next

using "rollapply" to calculate a moving sum or running sum?

This is not critical, but I am curious to learn. Are there any
suggestions for speeding up the process to calculate a moving row sum?
(Ideally from within R, as opposed to suing C, etc.)
Using rollapply on a matrix of 45,000 rows and 400 columns takes 83 minutes.

date()
mymatrix <- matrix(data=1:45000, nrow=45000, ncol=400)
temp <- t(rollapply(t(mymatrix), width=12, FUN=sum, by.column=T,
fill=NA, partial=FALSE, align="left"))
date()
On Thu, Jun 27, 2013 at 2:41 PM, arun <smartpink111 at yahoo.com> wrote: