Hello,
Try the following. (I don't remember who wrote this function but I saw
it in R-Help)
setdiffDF <- function(A, B){
f <- function(A, B)
A[!duplicated(rbind(B, A))[nrow(B) + 1:nrow(A)], ]
df1 <- f(A, B)
df2 <- f(B, A)
rbind(df1, df2)
}
df1 <- data.frame(A = 1:10, B = 11:20)
df2 <- data.frame(A = 1:5, B = 11:15)
setdiffDF(df1, df2)
Hope this helps,
Rui Barradas
Em 31-10-2013 19:58, Yasin Gocgun escreveu:
Hi,
I have two data frames, say, x and y, where y is a subset of x. How
can I find the set difference of these two data frames (i.e., x-y)?
Thanks,
______________________________________________
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.