Re: [R] Find backward duplicates in a data frame

2013-11-15 Thread arun
Hi,May be: fun1 <- function(dat){ indx <- apply(dat,1,function(x) {         any(x==sort(x))| !any(as.character(interaction(dat,sep="")) %in% paste(sort(x),collapse=""))         }) dat[indx,] } test1 <- rbind(test,data.frame(a="F",u="E")) fun1(test) fun1(test1) A.K. On Friday, November 15

Re: [R] Find backward duplicates in a data frame

2013-11-15 Thread MacQueen, Don
So rows are considered duplicated if they have the same two characters, regardless of which column they're in? If the B A row came first is it ok to keep that row, or would you want to keep the A B row? This appears to work, at least for this example. foo <- t(apply(test,1, function(x) sort(fo

[R] Find backward duplicates in a data frame

2013-11-15 Thread Hermann Norpois
Hello, I am looking for a method to eliminate rows dupblicates in a backwards manner, for instance: I want to keep A B but not B A (see my data.frame test). Thanks Hermann > test a u 1 A B 2 A C 3 B A 4 B F 5 C A 6 D W > dput (test) structure(list(a = structure(c(1L, 1L, 2L, 2L, 3L, 4L), .Label