开发者

How to reduce the array dimensions in R?

开发者 https://www.devze.com 2023-01-19 00:39 出处:网络
Suppose I have a data array, dat <- array(NA, 开发者_如何学Goc(115,45,10)) How can I get a new data array

Suppose I have a data array,

dat <- array(NA, 开发者_如何学Goc(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


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消