I am afraid that neither the correct answers correspond to a semi join , nor intersect or merge . merge and intersect will not handle duplicate lines properly. sem join will reorder the lines.
From this point of view, I think that the only right one is still Akrun's.
You can also do something like:
df1[rowSums(((df1 == df2) | (is.na(df1) & is.na(df2))), na.rm = T) == ncol(df1),]
But I think that the acrun method is more elegant and probably works better in terms of speed.
source share