Skip to content
Prev 350913 / 398502 Next

binding two lists of lists of dataframes together

On May 14, 2015, at 7:15 AM, Vin Cheng wrote:

            
I suppose there might be a way to make it back into a data.table, but it won't be a structure that I would recognize as such. The usual data table column is a vector, whereas your object had a complex list structure stored as a single "column". It was list1 and list 2 that had the class attribute of c('data.table', 'data.frame'), rather than each list component having those attributes which might have made more sense.

If there is some virtue in the origianl structure that I am not appreciating, then just this:

list3a <- data.table(list3a)   # untested
The code I used to build colnames was just:

list1a <- lapply(list1, function(x) setNames( data.frame(x),
                                               paste0("V", seq(length(x)) )
                ) )

So modifying it to put that character vector in the  names attribute on list3a itself could just be:

list3a <- lapply(list3a, function(x) setNames( data.frame(x), 
                                               c("id","WgtBand","Wgt","Held","LID","Issuer","Bid","Offer") ) )