I have a large 3 dimensional array of size (243,246,768) The first dimension is Rows, second is columns and the third is Time.
So for each row and column, I want to calculate the mean of time steps 1:8, 2:9, 3:10 and so on and assign the values to a new array. For this I am using the following script. for(i in 1:243) { for(j in 1:246) { for(k in 1:768) { newVar[i,j,k] <- mean( myVar[i,j,k:k+7]) } } } This works, but needless to mention it take a very long time to loop over all the rows, columns and time periods. I was wondering if there is a simpler way to do this. Thanks Aparna ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.