How to declare list object with M elements
Maybe this:
myls <- vector("list", length = S)
Try
mylist <- rep(list(elm),7)
which, for S=3, gives
[[1]]
[,1] [,2] [,3]
[1,] NA NA NA
[2,] NA NA NA
[3,] NA NA NA
[[2]]
[,1] [,2] [,3]
[1,] NA NA NA
[2,] NA NA NA
[3,] NA NA NA
[[3]]
[,1] [,2] [,3]
[1,] NA NA NA
[2,] NA NA NA
[3,] NA NA NA
By the way, identical(matrix(NA,3,3),matrix(,3,3))
is true, since matrices are initialized to NA
by default. See ?matrix
.