Good morning, I have two datasets with the exact same columns. I would like to select rows that have a matching ID between the two datasets (Please, see tables below).I tried to merge datasets with the r bind function but all rows were included. Do you have some advice to keep only rows with a matching ID?

Input

df1

ID VAR 1 VAR 2

a ... ...

b ... ...

c ... ...

d ... ...

df2

ID VAR 1 VAR 2

a ... ...

b ... ...

e ... ...

f ... ...

Output

df

ID VAR 1 VAR 2

a ... ...

b ... ...

More Inès François's questions See All
Similar questions and discussions