Skip to content
Prev 286395 / 398502 Next

find difference between data frames

I'm not sure if you mean to ignore row 6 while ignoring row 4 or not
so here are two solutions (depending on what you meant)

dput(x) # dput is your friend
structure(list(kind = c(1L, 1L, 1L, 1L, 2L, 2L), x = c(8L, 44L,
25L, 36L, 2L, 36L), y = c(9L, 3L, 7L, 20L, 14L, 20L)), .Names = c("kind",
"x", "y"), class = "data.frame", row.names = c("1", "2", "3",
"4", "5", "6"))

## If you want to get rid of duplicates for both cases -- not the
prettiest but it works
table(x[!(duplicated(x[,-1], fromLast = TRUE) | duplicated(x[,-1])),1])

## If you only want to get rid of it for the kind==1 rows (assuming
the data.frame is sorted by kind)
table(x[!duplicated(x[,-1], fromLast = TRUE), 1])

It's usually good practice to say what the answer you expect is to
avoid this sort of confusion.

Michael
On Fri, Feb 24, 2012 at 2:00 PM, psy106616 <psy106616 at 163.com> wrote: