You can specify the common columns to merge
, which is what must be done here.
merge(x, y, by.x='A', by.y='C', all=TRUE) A B D1 4 1 3442 6 2 5493 9 2 NA4 10 3 2095 15 3 631
By default, merge
uses the intersection of the column names to specify the common columns between the two data frames. When there are no column names in common, or when this is the incorrect set, you must specify with by
or by.x
and by.y
.