Zé Pinho
Zé Pinho

Reputation: 83

How can I merge multiple data frames with the same columns in R?

I want to join multiple data frames(5), they are exactly equal to this sample: Place1

   Date        Sales Price SKU
    2007/01/02   1     1.29 52648
    2007/01/02   2     1.99 48721
    2007/01/02   5     0.55 65897
    2007/01/02   2     5.00 56482
    2007/01/02   10    2.50 46521

different data frames have the same columns but different rows and I want to join them. I tried with the function merge but only let me do with 2. How can i do?

Thanks

Upvotes: 3

Views: 11946

Answers (2)

A5C1D2H2I1M1N2O1R2T1
A5C1D2H2I1M1N2O1R2T1

Reputation: 193497

When your data have exactly the same columns and you are just looking to join them, you are generally not looking for merge but for rbind.

Since the number of data.frames is small, you should be able to just do:

rbind(Place1, Place2, Place3, Place4, Place5)

Alternatively, if you can get these all in a list, you can use:

do.call(rbind, your-list-of-dataframes)

Upvotes: 8

rnso
rnso

Reputation: 24535

Try rbind function:

rbind(df1, df2, df3, df4, df5)

or, if all df are in a list called dflist:

do.call(rbind, dflist)

Upvotes: 2

Related Questions