Hi,
 
Apologies for the newbie error.  Thanks John, Jim, Jeff!
 
Please find the dput output below.  I'm trying to take list1 and list 2 and 
bind them together at an individual list level by column - all the structures 
and col names will be the same, but the number of rows could be different for 
any sublist.  The output should end up looking like list3.  
 
Please let me know if this remains unclear.  Any help/guidance would be greatly 
appreciated!!
 
Many Thanks,
Vince
 
 
list1<-list(structure(list(id = c(493L, 564L, 147L, 83L, 33L, 276L, 402L, 285L, 
30L, 555L), 
                    WgtBand = c(1, 1, 2, 3, 4, 5, 6, 7, 8, 9), 
                    Wgt = c(NaN, NaN, NA, NA, NA, NA, NA, NA, NA, NA)), 
               .Names = c("id", "WgtBand", "Wgt")), 
     structure(list(id = c(76L, 330L, 574L, 47L, 131L, 581L, 133L, 69L, 35L, 
487L), 
                    WgtBand = c(1, 1, 2, 3, 4,5, 6, 7, 8, 9), 
                    Wgt = c(NaN, NaN, NA, NA, NA, NA, NA, NA, NA, NA)), 
               .Names = c("id", "WgtBand", "Wgt")), 
     structure(list(id = c(376L, 130L, 574L, 47L, 131L, 581L, 133L, 69L, 35L, 
487L), 
                    WgtBand = c(1, 1, 2, 3, 4,5, 6, 7, 8, 9), 
                    Wgt = c(NaN, NaN, NA, NA, NA, NA, NA, NA, NA, NA)), 
               .Names = c("id", "WgtBand", "Wgt")))


list2<-list(structure(list(id = c(493L, 564L, 147L), 
                           WgtBand = c(1, 2, 3), 
                           Wgt = c(NaN, NaN, NA)), 
                      .Names = c("id", "WgtBand", "Wgt")), 
            structure(list(id = c(276L, 411L, 574L,111L), 
                           WgtBand = c(1, 2, 3,4), 
                           Wgt = c(NaN, NaN, NA,NA)), 
                      .Names = c("id", "WgtBand", "Wgt")), 
            structure(list(id = c(76L, 330L), 
                           WgtBand = c(1, 1), 
                           Wgt = c(NaN, NaN)), 
                      .Names = c("id", "WgtBand", "Wgt")))

list3<-list(structure(list(id = c(493L, 564L, 147L, 83L, 33L, 276L, 402L, 285L, 
30L, 555L,493L, 564L, 147L), 
                           WgtBand = c(1, 1, 2, 3, 4, 5, 6, 7, 8, 9,1, 2, 3), 
                           Wgt = c(NaN, NaN, NA, NA, NA, NA, NA, NA, NA, 
NA,NaN, NaN, NA)), 
                      .Names = c("id", "WgtBand", "Wgt")), 
            structure(list(id = c(376L, 130L, 574L, 47L, 131L, 581L, 133L, 69L, 
35L, 487L,276L, 411L, 574L,111L), 
                           WgtBand = c(1, 1, 2, 3, 4,5, 6, 7, 8, 9, 1, 2, 3,4), 
                           Wgt = c(NaN, NaN, NA, NA, NA, NA, NA, NA, NA, 
NA,NaN, NaN, NA,NA)), 
                      .Names = c("id", "WgtBand", "Wgt")), 
            structure(list(id = c(76L, 330L, 574L, 47L, 131L, 581L, 133L, 69L, 
35L, 487L,76L, 330L), 
                           WgtBand = c(1, 1, 2, 3, 4,5, 6, 7, 8, 9, 1, 1), 
                           Wgt = c(NaN, NaN, NA, NA, NA, NA, NA, NA, NA, 
NA,NaN, NaN)), 
                      .Names = c("id", "WgtBand", "Wgt")))

 
 

 
From: newrnew...@hotmail.com
To: r-help@r-project.org
Date: Mon, 11 May 2015 21:07:02 +0000
Subject: Re: [R] binding two lists of lists of dataframes together

 
 
> From: newrnew...@hotmail.com
> To: r-help@r-project.org
> Date: Mon, 11 May 2015 20:16:40 +0000
> Subject: [R] binding two lists of lists of dataframes together
> 
>  Hi, 
> I'm new to R and am stumped.  I'm trying to bind List 1 to List 2 and have 
> the corresponding Output.  
>  
> I've found the following code - I can't say I understand 
> rbindlist(lapply(list12, "[", i, TRUE)).  Either way - it doesn't give 
> exactly what's needed.
>  
> library(data.table)
> list12 <- list(List1,List2)
> nr <- as.vector(nrow(list12[[1]]))
> fastbind.ith.rows <- function(i) rbindlist(lapply(list12, "[", i, TRUE))
> fastbound <- lapply(1:nr, fastbind.ith.rows)
>  
> It produces Output 2 - where dataframes are grouped together by rownames, but 
> keeps 2 separate vectors - vs. binding the two into 1 vector.
>  
> Any help/guidance would be greatly appreciated!!
>  
> Thanks!
> Vince
>  
                                          

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.              
                          
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to