Re: [R] list element to matrix

2007-09-06 Thread Jim Lemon
[EMAIL PROTECTED] wrote: > I have created a list of "matrices" using sapply or lapply and wish to > extract each of the "matrices" as a matrix. Some of them are 2x2, 3x3, etc. > > I can do this one at a time as: > > M1<-as.matrix(D[[1]]) > > How can repeat this process for an unknown number of

Re: [R] list element to matrix

2007-09-05 Thread jim holtman
If they are already a matrix in the list, then you don't have to use 'as.matrix'; you can just say: M1 <- D[[1]] Now the question is, what do you mean by how do you index M1? Do you want to go through the list applying a function to each matrix? If so, then just 'lapply'. For example, to get t

[R] list element to matrix

2007-09-05 Thread Friedrich Schuster
You get the number of list elements with length(D), the dimensions of M1 with dim(M1) see help with: ?dim ?length Hope this helps... >I have created a list of "matrices" using sapply or lapply and wish to >extract each of the "matrices" as a matrix. Some of them are 2x2, 3x3, etc. >I can d

[R] list element to matrix

2007-09-05 Thread dverzi
I have created a list of "matrices" using sapply or lapply and wish to extract each of the "matrices" as a matrix. Some of them are 2x2, 3x3, etc. I can do this one at a time as: M1<-as.matrix(D[[1]]) How can repeat this process for an unknown number of entries in the list? In other words, h