I have two dataframes and I'm trying to merge them based on MarkerName, Allele1, and Allele2. My issue is that the allele 1 and allele 2 columns can sometimes be flipped and are different cases (i.e. line 1 in both examples below). Additionally, sometimes the MarkerName can be duplicated (line 3 and 4).
Here are the examples:
MarkerName id Allele1 Allele2
1: 1:752721 rs3131972 A G
2: 1:791853 rs6684487 G A
3: 1:834056 rs28482280 A C
4: 1:834056 rs28482282 A CAC
5: 1:834059 rs28482242 A C,G
and
MarkerName Allele1 Allele2 Effect
1: 1:752721 g a -0.0018
2: 1:791853 g a 0.0408
3: 1:834056 a c 0.0079
Is there a way to add the id column to the second dataframe in R? So it would look something like this in the end:
MarkerName Allele1 Allele2 Effect id
1: 1:752721 g a -0.0018 rs3131972
2: 1:791853 g a 0.0408 rs6684487
3: 1:834056 a c 0.0079 rs28482280