Reputation: 83
I would like a "2-dimensional list" where entry (i, j) stores a vector/matrix of unknown size. Something like
my2Dlist[i,j] <- runif(k)
where k
varies with i
and j
. What is the data structure I am looking for?
Thank you.
Upvotes: 0
Views: 1493
Reputation: 83
Self-Answer: The solution I found is as follows. If I want a 2x2 list, I write
my2Dlist <- as.list(1:4)
dim(my2Dlist) <- c(2,2)
One can then store anything in the components, for example
my2Dlist[[1,2]] <- c(1, 1, 2, 3, 5, 8)
Upvotes: 5