[R] A list within a list?

David Scott d.scott at auckland.ac.nz
Sun Feb 6 04:04:23 CET 2011


On 6/02/2011 3:38 p.m., Jim Silverton wrote:
> Hello,
> I am planning of building a list of lists specifically,  my first list is
> some what of the sort:
> lidta<- list(m, p, r, s, q, A, B)
> where A and B are matrices that may be of different number of rows . The
> number of rows in matrix A and matrix B depends on the the values of m.
>
> The question is I don;t know how to put all the 1000 or so of these lists
> into a 'mega' list.
>
> Can you help me?
>
>
>
>
I use the following for this sort of thing.

megaList <- vector("list", length = 1000)
testList <- list(x=1:3, y=c("a","b"))
for (i in 1:1000){
     megaList[[i]] <- testList
}
head(megaList)

David Scott



_________________________________________________________________
David Scott	Department of Statistics
		The University of Auckland, PB 92019
		Auckland 1142,    NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:	d.scott at auckland.ac.nz,  Fax: +64 9 373 7018

Director of Consulting, Department of Statistics



More information about the R-help mailing list