[R] efficiently diff two data frames

Liviu Andronic landronimirc at gmail.com
Fri Apr 19 15:26:44 CEST 2013


Dear Rui,
Thanks for the pointer.


On Tue, Apr 16, 2013 at 8:12 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote:
> setdiffDF2 <- function(A, B){
>     f <- function(X, Y)
>         !duplicated(rbind(Y, X))[nrow(Y) + 1:nrow(X)]
>     ix1 <- f(A, B)
>     ix2 <- f(B, A)
>     ix1 & ix2
> }
> ix <- setdiffDF2(Xe, Xf)
> Xe[ix,]
> Xf[ix,]
>
>
> Note that this gives no information on the columns.
>
This seems to work nicely on the rows. But what about the columns? How
would I take the resulting subsets and diff column by column?

Thanks,
Liviu



More information about the R-help mailing list