\HeaderA{rev}{Reverse Elements}{rev}
\methaliasA{rev.default}{rev}{rev.default}
\keyword{manip}{rev}
\begin{Description}\relax
\code{rev} provides a reversed version of its argument.  It is generic
function with a default method for vectors and one for
\code{\LinkA{dendrogram}{dendrogram}}s.

Note that this is no longer needed (nor efficient) for obtaining
vectors sorted into descending order, since that is now rather more
directly achievable by \code{\LinkA{sort}{sort}(x, decreasing = TRUE)}.
\end{Description}
\begin{Usage}
\begin{verbatim}
rev(x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] a vector or another object for which reversal is defined.
\end{ldescription}
\end{Arguments}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{seq}{seq}}, \code{\LinkA{sort}{sort}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- c(1:5,5:3)
## sort into descending order; first more efficiently:
stopifnot(sort(x, decreasing = TRUE) == rev(sort(x)))
stopifnot(rev(1:7) == 7:1)#- don't need 'rev' here
\end{ExampleCode}
\end{Examples}

