5

I would like to use the dplyr package (like the pipe operator: %>%) when i bind rows from several lists.

Now the issue is that I need the list names also to be added to the column. With do.call(rbind, list) this happens automatically, what is the dplyr equivalent?

I've tried list.object %>% rbind_all() and list.object %>% bind_rows which gives the same effect with no list names following.

uncool
  • 2,613
  • 7
  • 26
  • 55
  • 1
    Using `data.table` , `rbindlist(yourlist, idcol=TRUE)` – akrun Oct 30 '15 at 16:50
  • 7
    In the current version of **dplyr** `bind_rows` has a `.id` argument, along the same lines as outlined above for **data.table**. – joran Oct 30 '15 at 16:54
  • thank you @joran just what I was looking for! – uncool Oct 30 '15 at 16:55
  • I found the last suggestion in the accepted answer here very helpful: https://stackoverflow.com/questions/8753531/repeat-rows-of-a-data-frame-n-times – Earlien Jan 06 '23 at 03:59

0 Answers0