1

I have this list:

list(structure(list(year = numeric(0), quarter = numeric(0), 
    Other = numeric(0), flow = character(0), country = character(0), 
    imfcode = integer(0), ISO3C = character(0)), row.names = integer(0), class = "data.frame"), 
    structure(list(year = numeric(0), Other = numeric(0), flow = character(0), 
        country = character(0), 
 ISO3C = character(0)), row.names = integer(0), 
class = "data.frame"))

Each element of the list is a dataframe, I believe, although class() says that each element is actually a list of a dataframe. I wish to rbind all of these dataframes together. Is there an efficient way to do this? Thank you!

Min Nguyen
  • 45
  • 3
  • 5
    You can use `rbindlist(lst1)` from `data.table` or `bind_rows(lst1)` from `dplyr` – akrun Dec 10 '19 at 23:31
  • This might help :- https://stackoverflow.com/questions/18003717/efficient-way-to-rbind-data-frames-with-different-columns – Ronak Shah Dec 10 '19 at 23:55
  • @akrun: holy! that's so efficient. I didn't know the existence of this function in the dplyr package. Thanks a lot! – Min Nguyen Dec 11 '19 at 20:41

1 Answers1

0

We can use rbindlist from data.table

library(data.table)
rbindlist(lst1)

Or

library(dplyr)
bind_rows(lst1)
akrun
  • 874,273
  • 37
  • 540
  • 662