This is a subset of data frame F1:
id code s-code
l.1 1 11
l.2 2 12
l.3 3 13
f.1 4 NA
f.2 3 1
h.1 2 1
h.3 1 1
I need to compare the F1.id with F2.id and then add the differences in column "id" to the F2 data frame and fill in columns' values for the added "id" with 0.
this is the second data frame F2:
id head sweat pain
l.1 1 0 1
l.3 1 0 0
f.2 3 1 1
h.3 1 1 0
The output should be like this:
F3:
id head sweat pain
l.1 1 0 1
l.3 3 13 0
f.2 3 1 1
h.1 2 1 1
h.3 1 1 0
l.2 0 0 0
h.1 0 0 0
f.1 0 0 0
I tried different solution, such as
F1[(F1.index.isin(F2.index)) & (F1.isin(F2))] to return the differences, but non of them worked.