TomTe
TomTe

Reputation: 319

How can you merge data frames one below the other instead of next to each other (left-right)?

I have two data sets as CSV files with identical columns.
I want to merge them so that they are listed one below the other.

I tried this code but this only puts them together left to right:

merge(1, 2, by="Col A") 

I am looking to list them one above the other in the merged data set, not next to each other.

enter image description here

Upvotes: 0

Views: 1496

Answers (1)

mnist
mnist

Reputation: 6954

You can use bind_rows() from dplyr. For a discussion why bind_rows can sometimes be preferrable over rbind() see the discussion here

one <- mtcars[1:4, ]
two <- mtcars[11:14, ]

# You can supply data frames as arguments:
bind_rows(one, two)

Upvotes: 2

Related Questions