I'm not sure I understand your question: a[[2]] is a matrix. > a <- list(matrix(1:6,2),matrix(5:10,2)) > is.matrix(a[[2]]) TRUE x = a[[2]] > is.matrix(x) TRUE > x+2 [,1] [,2] [,3] [1,] 7 9 11 [2,] 8 10 12 > a[[2]] + 2 [,1] [,2] [,3] [1,] 7 9 11 [2,] 8 10 12
What else do you need? Michael Weylandt On Wed, Aug 24, 2011 at 2:28 PM, Chee Chen <chee.c...@yahoo.com> wrote: > Dear All, > As always, I appreciate all your help. > I would like to know the easiest way to convert each of the homogeneous > elements of a numeric list into a matrix. Each element of this list is also > a list such that when displayed, looks like a 2-by-3 matrix , I would like > to convert each of them into a matrix, without changing the double index of > each entry. > > Suppose: > a<- vector("list",2) > > a[[1]] > [,1] [,2] [,3] > [1,] 1 2 0 > [2,] 3 4 5 > > > a[[2]] > [,1] [,2] [,3] > [1,] 5 6 9 > [2,] 7 8 10 > > >is.list(a[[1]]) > True > > Target: I would like to convert a[[2]] into a matrix, keeping the double > index, into > > mat1 > [,1] [,2] [,3] > [1,] 5 6 9 > [2,] 7 8 10 > > The list I have is huge and so is each of its elements, and do not want to > use unlist because I do not understand it fully. > Thank you, > Chee > > > [[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. > [[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.