[R] Concatenate two lists, list by list

PIKAL Petr petr.pikal at precheza.cz
Tue Jan 22 11:51:32 CET 2013


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



More information about the R-help mailing list