Sum values in a rolling/sliding window
What you have is a vector, not an array. You can use rollapply function from zoo package to get what you need. > x <- c(1, 2, 3, 10, 20, 30) > #library(zoo) > rollapply(x, 3, sum) [1] 6 15 33 60 Take a look at ?rollapply for further details on what rollapply does and … Read more