[R] Concatenate two lists, list by list

D. Rizopoulos d.rizopoulos at erasmusmc.nl
Wed Jan 23 11:08:48 CET 2013


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>
>
> 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] 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 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/


More information about the R-help mailing list