Skip to content
Back to formatted view

Raw Message

Message-ID: <2018A7D503F84748AECB8E75D4284117014E92D9@uspalex04.epri.com>
Date: 2009-02-27T23:15:24Z
From: Vemuri, Aparna
Subject: Large 3d array manipulation

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