I tried using the merge function here, but I am stumped. I apologize, because this seems basic, but the by.x and by.y functions are quite confusing to me. I would like to extract the shared columns between dataframe A and dataframe B, and then merge the two dataframes together. The dataframes do not share any Taxa (the first column) but they will share a portion of columns X1 - X10000, etc. Each of these dataframes has ~8,000 columns and a few hundred rows. In this example, variables X2 and X5 are shared, but the other variables X1 and X3 are not shared. Based on intersecting column name vectors, I know that the dataframes share ~3000 columns.
Dataframe A:
Taxa X1 X2 X5
118 T N A
113 N N A
60 C Y G
121 N N N
Dataframe B:
Taxa X2 X3 X5
200 C G N
119 T N G
30 C G G
21 C N N
Desired merged dataframe:
Taxa X2 X5
118 N A
113 N A
60 Y G
121 N N
200 C N
119 T G
30 C G
21 C N
When I try using the merge function, in a variety of ways, I get this (with my actual column numbers here):
Taxa X408050 X995019
NA <NA> <NA> <NA>
NA.1 <NA> <NA> <NA>
NA.2 <NA> <NA> <NA>
NA.3 <NA> <NA> <NA>
NA.4 <NA> <NA> <NA>
NA.5 <NA> <NA> <NA>
NA.6 <NA> <NA> <NA>