I got a problem when trying to merge two dataframes in R and I need your help. Suppose that I have following dataframes:
> Data_A
Code year score
A 1991 1
A 1992 2
A 1993 3
B 1991 3
B 1993 7
> Data_B
Code year l.score
A 1991 NA
A 1992 1
A 1993 2
A 1994 3
B 1991 NA
B 1992 3
B 1993 NA
B 1994 7
And the desire result after merging them should be like that:
> Data_merge
Code year score l.score
A 1991 1 NA
A 1992 2 1
A 1993 3 2
B 1991 3 NA
B 1993 7 NA
It means that when merging these dataframes, share columns in one will be kept (in this case, "Code" and "year" of Data_A). I tried merge(Data_A, Data_B, all = FALSE)
but not success. Someone have any idea? Thanks for reading!