saverio vicario
2006-Mar-24 18:42 UTC
[R] how to add list to a list in iterative manner without mixing content
I have a function that generated list and then from those I need to do some repeated calculation. So I was thinking to put them in another list and call them one after the other. Given that I have 20 of those it was a bit annoying to typing all of them in one command. So I need something to do a recursive addition of a list objet to a list here a small size example A<-list() D<-list(a=4, b=2) C<-list(a=3, b=4) I would like to this but without typing D and C A<-list(D,C) A Something like where I add new object list to the big list, but without that the element got mixed across my sublist as when I type : A<-c(A,D) A<-c(A,C) A
jim holtman
2006-Mar-25 02:44 UTC
[R] how to add list to a list in iterative manner without mixing content
Is this what you want?> A <- list() > # setup a counter > counter <- 0 > A[[counter <- counter+1]] <- C > A[[counter <- counter+1]] <- D > A[[1]] [[1]]$a [1] 3 [[1]]$b [1] 4 [[2]] [[2]]$a [1] 4 [[2]]$b [1] 2 On 3/24/06, saverio vicario <saverio.vicario@yale.edu> wrote:> > I have a function that generated list and then from those I need to > do some repeated calculation. So I was thinking to put them in > another list and call them one after the other. Given that I have 20 > of those it was a bit annoying to typing all of them in one command. > So I need something to do a recursive addition of a list objet to a > list > here a small size example > A<-list() > D<-list(a=4, b=2) > C<-list(a=3, b=4) > I would like to this but without typing D and C > A<-list(D,C) > A > Something like where I add new object list to the big list, but > without that the element got mixed across my sublist as when I type : > A<-c(A,D) > A<-c(A,C) > A > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >-- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What the problem you are trying to solve? [[alternative HTML version deleted]]