Skip to content
Prev 107042 / 398498 Next

Fast Removing Duplicates from Every Column

Hi

I am not sure if I understand how do you want to select unique items.

with
 sapply(DF, function(x) !duplicated(x))
you can get data frame with TRUE when an item in particular column is 
unique and FALSE in opposite. However then you need to choose which 
rows to keep or discard

e.g.

DF[rowSums(sapply(comp, function(x) !duplicated(x)))>1,]

selects all rows in which are 2 or more unique values.

HTH
Petr
On 5 Jan 2007 at 9:54, Bert Jacobs wrote:
From:           	"Bert Jacobs" <b.jacobs at pandora.be>
To:             	"'R help list'" <r-help at stat.math.ethz.ch>
Date sent:      	Fri, 5 Jan 2007 09:54:17 +0100
Subject:        	Re: [R] Fast Removing Duplicates from Every Column
Petr Pikal
petr.pikal at precheza.cz