You might need to implement it as a nested pair of for loops using rbind. In essence iterate over the rows in df1 and each time find the matching row in df2. If none is found then add the df1 row by itself to the result. If one is then remove it from df2 and rbind both of them. Once done just merge in all rows that remain in df2.
This would likely be slower than a sql-based method but is essentially the same algorithm. You can find advice on for-loops in R here: http://paleocave.sciencesortof.com/2013/03/writing-a-for-loop-in-r/ Best, Collin. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.