[R] Deleting repeated rows

Etienne B. Racine etiennebr at gmail.com
Fri Jun 26 15:43:57 CEST 2009




dreamworx wrote:
> 
> Appologies if this is a simple problem. I have a matrix which is 86x3 and
> each row contains three integers. The problem I have is that some of the
> rows of integers are repeated in other rows and I only wish to have one
> copy of these rows.
> 
> Is there a function that I can use which will identify these repeated rows
> and delete them from the matrix? I have searched for help with this
> problem but the only function I have found is 'grep' which I'm not sure is
> of any use.
> 

?unique

# generate data
set.seed(1001)
m <- matrix(sample(1:3,20*3,TRUE),ncol=3);m

# get unique values
unique(m)

As you can see, row 7 and 20 are 1,1,1... and you get only one row with
1,1,1 in the second matrix.

-- 
View this message in context: http://www.nabble.com/Deleting-repeated-rows-tp24219989p24220573.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list