Assume we have some matrix r
such that :
m=structure(c(1, 0.996805114543033, 0.987281571590291, 0.971610767189123,
0.950088633802627, 0.996805114543033, 0.993620436379149, 0.984127320055285,
0.996805114543033, 1, 0.996805114543033, 0.987281571590291, 0.971610767189123,
0.993620436379149, 0.996805114543033, 0.993620436379149, 0.987281571590291,
0.996805114543033, 1, 0.996805114543033, 0.987281571590291, 0.984127320055285,
0.993620436379149, 0.996805114543033, 0.971610767189123, 0.987281571590291,
0.996805114543033, 1, 0.996805114543033, 0.968506582079198, 0.984127320055285,
0.993620436379149, 0.950088633802627, 0.971610767189123, 0.987281571590291,
0.996805114543033, 1, 0.947053209443661, 0.968506582079198, 0.984127320055285,
0.996805114543033, 0.993620436379149, 0.984127320055285, 0.968506582079198,
0.947053209443661, 1, 0.996805114543033, 0.987281571590291, 0.993620436379149,
0.996805114543033, 0.993620436379149, 0.984127320055285, 0.968506582079198,
0.996805114543033, 1, 0.996805114543033, 0.984127320055285, 0.993620436379149,
0.996805114543033, 0.993620436379149, 0.984127320055285, 0.987281571590291,
0.996805114543033, 1), .Dim = c(8L, 8L))
k=5
inds <- which(`dim<-`(m %in% head(sort(c(m)), k), dim(m)), arr.ind = TRUE)
r=inds[order(m[inds]), ]
print(r)
row col
[1,] 6 5
[2,] 5 6
[3,] 5 1
[4,] 1 5
[5,] 6 4
[6,] 7 5
[7,] 4 6
[8,] 5 7
dput(r)
structure(c(6L, 5L, 5L, 1L, 6L, 7L, 4L, 5L, 5L, 6L, 1L, 5L, 4L,
5L, 6L, 7L), .Dim = c(8L, 2L), .Dimnames = list(NULL, c("row",
"col")))
I'm searching to drop duplicated rows of the r
matrix. The duplicated rows in this context are rows that represent a permutation of other's. For example : row1=c(6,5) & row2=c(5,6)
are duplicated => so I need to remove one of them.
Thank you for help !