\HeaderA{xtfrm}{Auxiliary Function for Sorting and Ranking}{xtfrm}
\methaliasA{xtfrm.Date}{xtfrm}{xtfrm.Date}
\methaliasA{xtfrm.default}{xtfrm}{xtfrm.default}
\methaliasA{xtfrm.factor}{xtfrm}{xtfrm.factor}
\methaliasA{xtfrm.POSIXct}{xtfrm}{xtfrm.POSIXct}
\methaliasA{xtfrm.POSIXlt}{xtfrm}{xtfrm.POSIXlt}
\methaliasA{xtfrm.Surv}{xtfrm}{xtfrm.Surv}
\keyword{univar}{xtfrm}
\keyword{manip}{xtfrm}
\begin{Description}\relax
A generic auxiliary function that produces a numeric vector which
will sort in the same order as \code{x}.
\end{Description}
\begin{Usage}
\begin{verbatim}
xtfrm(x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] an \R{} object.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This is a special case of ranking, but as a less general function than
\code{\LinkA{rank}{rank}} is more suitable to be made generic.  The default
method is equivalent to \code{rank(x, ties.method="min",
    na.last="keep")}, so \code{NA} values are given rank \code{NA} and
all tied values are given equal integer rank.

The \code{\LinkA{factor}{factor}} method extracts the codes.  The
\code{\LinkA{Surv}{Surv}} method sorts first on times and then on
status code(s).

The default method will make use of \code{==}, \code{>}  and
\code{is.na} methods for the class of \code{x}, but might be rather
slow when doing so.
\end{Details}
\begin{Value}
A numeric (usually integer) vector of the same length as \code{x}.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{rank}{rank}}, \code{\LinkA{sort}{sort}}, \code{\LinkA{order}{order}}.
\end{SeeAlso}

