Togaware DATA MINING
Desktop Survival Guide
by Graham Williams
Google

Removing Duplicates

The function duplicated identifies elements of a data structure that are duplicated:

> x <- c(1, 1, 1, 2, 2, 2, 3, 3, 3, 3)
> duplicated(x)
 [1] FALSE  TRUE  TRUE FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE
> x <- x[!duplicated(x)]
> x
[1] 1 2 3
>

This is a simple example, but works just as well to remove duplicated rows from a matrix or data frame.



Copyright © 2004-2006 Graham.Williams@togaware.com
Support further development through the purchase of the PDF version of the book.
Brought to you by Togaware.