mfk534
mfk534

Reputation: 719

Combine list data in R using Merge?

I would like to combine two lists:

data1 data2
a 1     a 1
b 2     b 2
c 3     c 3
d 4     f 6
e 5     g 7

so that the final product is:

data3
a 1
b 2
c 3
d 4
e 5
f 6
g 7

I have tried using variations of merge, but inevitably end up loosing something from each list.

Thank you for your help! Thank you!

Upvotes: 0

Views: 3158

Answers (2)

aatrujillob
aatrujillob

Reputation: 4826

use the argument all=TRUE of merge:

merge(data1,data2,all=TRUE)

Upvotes: 6

Henry
Henry

Reputation: 6784

One option to consider is

unique(rbind(data1, data2 ) )

Upvotes: 2

Related Questions