Skip to content
Back to formatted view

Raw Message

Message-ID: <4EADE26F.4020304@gmail.com>
Date: 2011-10-30T23:49:03Z
From: Wet Bell Diver
Subject: finding row duplicates, regardless of element order
In-Reply-To: <69CE0AD7-C079-45F6-8E7B-FA7A330F4282@gmail.com>

Dear list,

Suppose I have the following matrix:
 > M <- 
matrix(c("1","2","3","2","4","5","5","3","2","1","3","2","4","4"), ncol=2)
 > M
      [,1] [,2]
[1,] "1"  "3"
[2,] "2"  "2"
[3,] "3"  "1"
[4,] "2"  "3"
[5,] "4"  "2"
[6,] "5"  "4"
[7,] "5"  "4"

In this matrix, row 1 contains elements "1" and "3" and row 3 does the 
same. Similarly, rows 6 and 7 contain the same elements. I am looking 
for a way to efficiently identify these rows. I cannot use 
duplicated(M), since the order of the names in the rows does not matter, 
all that matters is that *all* names in a row also *all* appear in 
another row.
How can I identify such "duplicated" rows, without going through a 
process of looping and shifting elements around?

thanks, Peter