\Header{unique}{Extract Unique Elements}
\keyword{manip}{unique}
\keyword{logic}{unique}
\begin{Usage}
\begin{verbatim}
unique(x)
\end{verbatim}
\end{Usage}
\begin{Description}
\texttt{unique} returns a vector like \texttt{x}
but with duplicate elements removed.
If an element is equal to one with a smaller index, it is removed.\end{Description}
\begin{SeeAlso}
\texttt{\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=T)))# ~= 100(1 - 1/e) = 63.21
my.unique <- function(x) x[!duplicated(x)]
for(i in 1:4) { x <- rpois(100, pi); print(all(unique(x) == my.unique(x))) }
\end{ExampleCode}
\end{Examples}

