My problem seems to be very simple but I'm not able to solve it since hours…
I have a matrix such this one:
[,1] [,2]
[1,] 1 2
[2,] 2 1
[3,] 2 1
[4,] 3 4
I want to select the rows which have the same information, without regard to the order of the column. For instance row1 (1;2) and row2 (2;1). Then, i want to delete them, except one.
I have written this function, but it doesn't work…
f<-function(x){
i<-1
repeat
{
a<-c()
a<-c(which(x[i,1]==x[,2] & x[i,2]==x[,1]))
if(!is.null(a)) {x<-x[-c(a),]}
if(i>=nrow(x)) {break} else {i<-i+1}
}
x
}
f(data)
Somebody could give me a hint for this ?