\Header{unique}{Extract Unique Elements}
\methalias{unique.data.frame}{unique}
\methalias{unique.default}{unique}
\keyword{manip}{unique}
\keyword{logic}{unique}
\begin{Description}\relax
\code{unique} returns a vector or data frame like \code{x} but with duplicate
elements removed.  If an element is equal to one with a smaller index,
it is removed.\end{Description}
\begin{Usage}
\begin{verbatim}
unique(x, incomparables = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] an atomic vector or a data frame.
\item[\code{incomparables}] a vector of values that cannot be compared.
Currently, \code{FALSE} is the only possible value, meaning that all
values can be compared.
\end{ldescription}
\end{Arguments}
\begin{SeeAlso}\relax
\code{\Link{duplicated}} which gives the indices of duplicated
elements.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
unique(c(3:5, 11:8, 8 + 0:5))
length(unique(sample(100, 100, replace=TRUE)))
## approximately 100(1 - 1/e) = 63.21
my.unique <- function(x) x[!duplicated(x)]
for(i in 1:4)
 { x <- rpois(100, pi); stopifnot(unique(x) == my.unique(x)) }

data(iris)
unique(iris)
stopifnot(dim(unique(iris)) == c(149, 5))
\end{ExampleCode}
\end{Examples}

