Yeah, that sounds inefficient to me also. I think you'd be better off using multidimensional arrays instead of lists, since all your values are numeric. See ?array.
Miguel 2010/3/15 Márcio Resende <mresende...@yahoo.com.br> > > Hello R-helpers, > I have the following code that works well, > > b <-list() > for (i in 1:3){ > a <- matrix(runif(1),3,3) > b[[i]] <- a > } > b > > however, I need to do something similar with two loops and I was looking > for > something that would look like > > b <- list() > for (i in 1:3){ > for (j in 1:4){ > a <- matrix(runif(1),3,3) > b[[i,j]] <- a #but this doesn´t work > } > } > > Anyway, I wanted "b" to loop like > [[i=1, j=1]] [[i=1, j=2]] (...) > a[i=1, j=1] a[i=1,j=2] (...) > > [[i = 2, j=1]] (...) > a[i = 2, j = 1] (...) > > (...) > > Can anybody help me? > Thanks > > -- > View this message in context: > http://n4.nabble.com/storing-matrix-variables-in-loop-tp1593461p1593461.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.