Hi, I've had this problem for a while and tackled it is a quite dirty way so I'm wondering is a better solution exists:
If we have two vectors: v1 = c(0,1,2,3,4) v2 = c(5,3,2,1,0) How to remove one instance of the "3,1" / "1,3" double? At the moment I'm using the following solution, which is quite horrible: v1 = c(0,1,2,3,4) v2 = c(5,3,2,1,0) ft <- cbind(v1, v2) direction = apply( ft, 1, function(x) return(x[1]>x[2])) ft.tmp = ft ft[which(direction),1] = ft.tmp[which(direction),2] ft[which(direction),2] = ft.tmp[which(direction),1] uniques = apply( ft, 1, function(x) paste(x, collapse="%") ) uniques = unique(uniques) ft.unique = matrix(unlist(strsplit(uniques,"%")), ncol=2, byrow=TRUE) Any better solution would be very welcome! All the best, Emmanuel ______________________________________________ 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.