Concatenate two lists, list by list
In this example, I get the following: lis1 <- replicate(3, rnorm(5), simplify = FALSE) lis2 <- replicate(3, rnorm(5), simplify = FALSE) lis1 lis2 mapply(c, lis1, lis2, SIMPLIFY = FALSE) Best, Dimitris
On 1/23/2013 11:58 AM, Alaios wrote:
Thanks a lot. Unfortunately that did not help either. num [1:32003, 1:3] 0 0 0 0 0 0 0 0 0 0 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:32003] "" "" "" "" ... ..$ : NULL but I want to get
>> List of 3 >> $ : num [1:32002] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:32002] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:32002] 0 0 0 0 0 0 0 0 0 0 ... >> - attr(*, "dim")= int [1:2] 3 2 >>
I am sorry that I can not find reproducible example to show you Alex ------------------------------------------------------------------------ *From:* D. Rizopoulos <d.rizopoulos at erasmusmc.nl> *To:* Alaios <alaios at yahoo.com> *Cc:* PIKAL Petr <petr.pikal at precheza.cz>; R help <R-help at r-project.org> *Sent:* Wednesday, January 23, 2013 11:08 AM *Subject:* Re: [R] Concatenate two lists, list by list you just need: mapply(c, Part1$dataset, Part2$dataset, SIMPLIFY = FALSE) I hope it helps. Best, Dimitris On 1/23/2013 11:01 AM, Alaios wrote:
> Thanks a lot Petr, > for the answer > unfortunately that would convert everything to a matrix > > num [1:32002, 1:3] 0 0 0 0 0 0 0 0 0 0 ... > > but if you check below you can see that I Want those to form a list. > > Regards > Alex > > > > > ________________________________ > From: PIKAL Petr <petr.pikal at precheza.cz
<mailto:petr.pikal at precheza.cz>>
> > Sent: Tuesday, January 22, 2013 11:51 AM > Subject: RE: [R] Concatenate two lists, list by list > > Hi > > Maybe you could use mapply > > mapply(c, Part1$dataset,Part2$dataset) > > Regards > Petr >
>> -----Original Message----- >> From: r-help-bounces at r-project.org
<mailto:r-help-bounces at r-project.org> [mailto:r-help-bounces at r-
>> project.org <http://project.org/>] On Behalf Of Alaios >> Sent: Tuesday, January 22, 2013 11:26 AM >> To: R help >> Subject: [R] Concatenate two lists, list by list >> >> Dear all, >> I would like to concatenate the lists below >> >> str(Part2$dataset) >> List of 3 >> $ : num [1:16001] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:16001] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:16001] 0 0 0 0 0 0 0 0 0 0 ... >> >> >> >> str(Part1$dataset) >> List of 3 >> $ : num [1:16001] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:16001] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:16001] 0 0 0 0 0 0 0 0 0 0 ... >> >> >> I tried concatenating those with: >> >>
>>> str(cbind(Part1$datase,Part2$dataset))
>> List of 6 >> $ : num [1:16001] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:16001] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:16001] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:16001] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:16001] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:16001] 0 0 0 0 0 0 0 0 0 0 ... >> - attr(*, "dim")= int [1:2] 3 2 >> >> >> but I want something different. To concatenate those into a list by >> list operation so I will end up with something looking like that >> >> str(concatenatedLists) >> >> List of 3 >> $ : num [1:32002] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:32002] 0 0 0 0 0 0 0 0 0 0 ... >> $ : num [1:32002] 0 0 0 0 0 0 0 0 0 0 ... >> - attr(*, "dim")= int [1:2] 3 2 >> >> >> Is there anything that can do that in R? >> >> Regards >> Alex >> [[alternative HTML version deleted]]
> [[alternative HTML version deleted]] > > > > ______________________________________________ > R-help at r-project.org <mailto:R-help at 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. > -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 Web: http://www.erasmusmc.nl/biostatistiek/
Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 Web: http://www.erasmusmc.nl/biostatistiek/