[R] changing the number of elements in a list

Luis Borda de Agua lbagua at gmail.com
Wed Jun 9 15:46:09 CEST 2010

I would like to have a list where each element is a matrix, for example:

my.list <- list(matrix(0, ncol=3, nrow=3),
                       matrix(0, ncol=3, nrow=3),
                       matrix(0, ncol=3, nrow=3))

The problem is, I would like to be able to change automatically the number of elements in the list (not only three as in the above example).

That is, the instruction creating the list would be a part of a function that has an inputing parameter stating how many elements (matrices) the list has. 

I have tried several things, but none worked. 
However, this seems to be a rather simple problem.
All help is welcome!


More information about the R-help mailing list