Skip to content
Prev 260614 / 398502 Next

Remove duplicate elements in lists via recursive indexing

Dear Janko,
I think requires a for loop. The approach I took here was mark the dups, then dump them all in one hit:

testData = expand.grid(letters[1:4],c(1:3))
testData$keep=F
uniqueIDS = unique(testData$Var1)
for(thisID in uniqueIDS) {
	firstCaseOnly = match(thisID,testData$Var1)
	testData[firstCaseOnly,"keep"]=T
}

(testData = testData[testData$keep==T,])
On 23 May 2011, at 11:59 AM, Janko Thyson wrote: