Skip to content
Prev 26956 / 63434 Next

setdiff for data frames

On Mon, 10 Dec 2007, Charles C. Berry wrote:

            
I was about to suggest using the approach taken by duplicated.data.frame, 
(which is to 'hash' the rows to a character vector) then call setdiff.
E.g.

a <- do.call("paste", c(A, sep = "\r"))
b <- do.call("paste", c(B, sep = "\r"))
A[match(setdiff(a, b),a), ]

Note that apply() is intended for matrices (not data frames) and the 
version given can do a horrendous amount of coercion, whereas the above 
does it only once.
No chance: if you have not found it in the archives, it is too rare a 
request.