my dummy data looks like:
df1:
rsID---------chr-----position
x--------------12------319
x--------------12------322
x--------------12------327
x--------------12------321
x--------------14-------412
x--------------15-------3123
x--------------17-------413
df2:
rsID---------chr-----position
rs12---------14-------412
rs20---------17-------413
My Expected result looks like:
rsID---------chr-----position
x--------------12------319
x--------------12------322
x--------------12------327
x--------------12------321
rs12---------14-------412
x-------------15-------3123
rs20---------17-------413
It means that I want to match rsIDs from df2 to that from df1 (in other words, replace 'x' from df1 with rsIDs from df2) only if corresponding values in two columns 'chr' and 'position' of df1 and df2 are the same. The other rsIDs do not change (still, 'x').
My attempt does not works:
df3 = ifelse(df1$chr == df2$chr & df1$position == df2$position, df1$rsID == df2$rsID, "x")