简体   繁体   中英

R: combine list of lists into a single dataframe

I have a list (res) containing pxb number of dataframes. Each dataframe has 12 columns but varying number of rows (eg, res[[1]][[1]] has 12 cols and 36 rows, but res[[1]][[1]] has 12 cols and 38 rows). I would like to combine them into a single dataframe that has 12 columns and 179 rows let's say. The do.call("rbind", listOfDataFrames) method doesn't work as I loose column and row information. Let me know, if further specification is needed. Many thanks!

In fact it is a list containing 5 elements. And the first element is a list of dataframes, whereas the other elements 2 , 3 , 4 and 5 are NULL . so you need to do access the first element of your list:

do.call(rbind, listOfDataFrames[[1]])

Or:

rbindlist(listOfDataFrames[[1]])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM