0

I have this list of 2 dataframes

ll = list(df1 = data.frame(x = 1:4),
          df2 = data.frame(y = 2:9) )

and I wish to obtain the following result

1  1
2  2
3  3
4  4
5  2
6  3
7  4
8  5
9  6
10 7
11 8
12 9
Anas116
  • 797
  • 2
  • 9
  • it does not answer my question because I have a list of dataframes – Anas116 Jul 26 '23 at 08:46
  • 2
    `data.frame(x = unname(unlist(ll)))` works. If you have data frames with more than one column, then `do.call("rbind", lapply(ll, setNames, nm = names(ll[[1]])))` is a more general solution. – Allan Cameron Jul 26 '23 at 08:51
  • 1
    If you want a `data.frame` as result `data.frame(col = unname(unlist(ll)))` will give you your desired output. Didn't see @AllanCameron comment. And I wonder if this question should be reopened, since the answers here differ from the linked thread. – TimTeaFan Jul 26 '23 at 09:05
  • 1
    I went a bit fast on the closing, but I also think some of the answers are scattered in multiple other questions (just saw that `data.table::rbindlist(ll, use.names = FALSE)` is another valid answer, taken from [here](https://stackoverflow.com/questions/66994102/combine-two-dataframes-by-row-irrespective-of-columns-names)). – Maël Jul 26 '23 at 09:12

0 Answers0