Skip to content
Prev 172156 / 398506 Next

Partial sum of a vector

perhaps this?

M <- dim(data_m)[2]

for(j in 1:M){
    for (i in 4:T) {
        data_q[i-3,j]=sum(data_m[(i-3):i,j])
    }
}

of course, you can vectorize this and speed it up significantly, but
there is something evil about premature optimization.
On Mar 2, 1:29?pm, Mohammad Sabr <mohammad_s... at yahoo.com> wrote: