在R中复制矩阵

时间:2014-04-01 17:40:52

标签: r

我有一个尺寸

的矩阵
M[360,180,120]
M <- array(0, dim = c(360,180,120))

另一个维度

C[360,180,12]
C <- array(0, dim = c(360,180,12))

我想要做的是创建一个维度为M的矩阵,用于存储C的值,例如

N[,,1] = C[,,1]
N[,,2] = C[,,2]
.
.
N[,,12] = C[,,12]
N[,,13] = C[,,1]
.
.
N[,,120] = C[,,12]

非常感谢

1 个答案:

答案 0 :(得分:1)

R会自动进行此回收。

C <- array(1:(360*180*12), dim = c(360,180,12))
N <- array(C, dim = c(360,180,120))

identical(N[,,120],C[,,12])
# [1] TRUE