R creating an array of matrices
data-structures, r
Solution
I'm probably missing the point, but won't:
k = 2; n=3; m = 4
array(NA, c(n,m,k))
, , 1
[,1] [,2] [,3] [,4]
[1,] NA NA NA NA
[2,] NA NA NA NA
[3,] NA NA NA NA
, , 2
[,1] [,2] [,3] [,4]
[1,] NA NA NA NA
[2,] NA NA NA NA
[3,] NA NA NA NA
give you what you want? Then you can loop as normal:
R> for(k in 1:2){print(a[,,k])}
Problem
I would like to create an array of matrices in such a way that I first create an array of k matrices with NA values and then loop over k and update each k'th matrix through the array. Any suggestions?