Extract dataframe from list of list

I have a list of two data frames. Again, I have such multiple lists with the same name of dataframes.
So, how can I extract or rbind all dataframes with simialar names.

For example:

  abc=data.frame(
    time=sample(100,10),
    value=sample(100,10)
  )
  
  xyz=data.frame(
    time=sample(100,10),
    value=sample(100,10)
  )
  
  
  listA=list(abc,xyz)
  listB=list(abc,xyz)
  listC=list(abc,xyz)
  listD=list(abc,xyz)
  listE=list(abc,xyz)
  listF=list(abc,xyz)
  
  listoflist=list(listA,listB,listC,listD,listE,listF)
  
  names(listoflist) <- c("1", "2","3","4","5","6")
  

I want to join all abc and xyz from each list.

Thank you

Is this what you are after?

library(tidyverse)
listoflist %>% 
  set_names(c("1", "2","3","4","5","6")) %>% 
  map_df(bind_rows,  .id = "source")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.