[R] list of matrices
R. Michael Weylandt
michael.weylandt at gmail.com
Wed Mar 21 17:21:10 CET 2012
You probably want
mylist[[i]] = function(...)
in your loop.
Similarly, when you want them again later, you need to use double
I once heard a useful metaphor for understanding the difference
between [ and [[ when it comes to lists.
If x (a list) is a train, then x is the second car of that train,
while x[] are the contents of that second car.
That's why things like, x[1:3] are well defined (the sublist
containing elements 1 through 3) while x[[1:3]] are not.
Hope this helps,
On Wed, Mar 21, 2012 at 11:08 AM, David Zastrau <davidz at tzi.de> wrote:
> Hello dear R-users,
> I am currently trying to fill some datasatructure (array, list, hash...)
> with matrices that are calculated by a function and do vary in size:
> mylist = list()
> for(i in 1:n)
> mylist[i] = function(...) # returns a matrix
> print(mylist) # prints only the first element of the matrix
> How can I store and afterwards access the matrices that are calculated by my
> Any help would be greatly appreciated!
> Best Wishes
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help