tags:

views:

46

answers:

1

Hi, all,

Suppose I have a data array,

dat <- array(NA, c(115,45,10))

How can I get a new data array

dat1<- array(NA, c(115,45)) by averaging dat by the third dimension?

Thanks

+2  A: 

Try this:

dat1 <- apply( dat, c(1,2), mean )

the c(1,2) means keep the 1st and 2nd dimensions and apply the function (mean) over the rest (3rd).

Greg Snow
Thanks. It works!
didimichael
+1 for "translation" :)
Brandon Bertelsen