Re: [R] Finding (swapped) repetitions of numbers pairs across two columns

2012-12-27 Thread arun
(apply(cbind(v1,v2),1,function(x) x[order(x)] #found to be faster #   user  system elapsed #  2.693   0.072   2.857  identical(res1,res3) #[1] TRUE A.K. - Original Message - From: Emmanuel Levy To: R-help Mailing List Cc: Sent: Thursday, December 27, 2012 3:30 PM Subject: [

Re: [R] Finding (swapped) repetitions of numbers pairs across two columns

2012-12-27 Thread Marc Schwartz
Yep. There are methods for: > methods(unique) [1] unique.array unique.data.frame unique.default [4] unique.matrix unique.numeric_version unique.POSIXlt and for the matrix and data.frame methods, unique rows will be returned by default. For array and matrix obje

Re: [R] Finding (swapped) repetitions of numbers pairs across two columns

2012-12-27 Thread Emmanuel Levy
I did not know that unique worked on entire rows! That is great, thank you very much! Emmanuel On 27 December 2012 22:39, Marc Schwartz wrote: > unique(t(apply(cbind(v1, v2), 1, sort))) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailm

Re: [R] Finding (swapped) repetitions of numbers pairs across two columns

2012-12-27 Thread Marc Schwartz
On Dec 27, 2012, at 2:30 PM, Emmanuel Levy wrote: > 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"

[R] Finding (swapped) repetitions of numbers pairs across two columns

2012-12-27 Thread Emmanuel Levy
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 q