2014-04-01 96 views
1

我有尺寸複製矩陣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

[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 
+0

也看看http://stackoverflow.com/questions/13693349/how-to-bind-the-same-vector-multiple-times/13693361#13693361和http://stackoverflow.com /問題/ 6555651 /下乜情況下,確實-R-回收/ 6555764#6555764 – kdauria