I want to combine two dataframes, df1
and df2
, by different groups of a key variable in x1
. It is basically some join operation, however, I do not want the rows to duplicate and do not care about the relationship among the added columns.
Assume:
df1
:
x1 x2
A 1
A 2
A 3
B 4
B 5
C 6
C 7
df2
:
x1 x3
A a
A b
A c
A d
A e
A f
B g
C h
The result should look like this.
df1
+ df2
:
x1 x2 x3
A 1 a
A 2 b
A 3 c
A NA d
A NA f
B 4 g
B 5 NA
C 6 h
C 7 NA
Does anyone have an idea? I would most appreciate your help!