\Header{rank}{Sample Ranks}
\keyword{univar}{rank}
\begin{Description}\relax
Returns the sample ranks of the values in a numeric vector.
Ties result in ranks being averaged.\end{Description}
\begin{Usage}
\begin{verbatim}
rank(x, na.last = TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a numeric vector.
\item[\code{na.last}] for controlling the treatment of \code{NA}s.
If \code{TRUE}, missing values in the data are put last; if
\code{FALSE}, they are put first; if \code{NA}, they are removed.
\end{ldescription}
\end{Arguments}
\begin{SeeAlso}\relax
\code{\Link{order}} and \code{\Link{sort}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
(r1 <- rank(x1 <- c(3,1,4,59,26)))
(r2 <- rank(x2 <- c(3,1,4,5,9,2,6,5,3,5))) # ties

## rank() is "idempotent": rank(rank(x)) == rank(x) :
stopifnot(rank(r1) == r1, rank(r2) == r2)
\end{ExampleCode}
\end{Examples}

