\Header{relevel}{Reorder Levels of Factor}
\methalias{relevel.default}{relevel}
\methalias{relevel.factor}{relevel}
\methalias{relevel.ordered}{relevel}
\keyword{utilities}{relevel}
\keyword{models}{relevel}
\begin{Description}\relax
The levels of a factor are re-ordered so that the level specified by
\code{ref} is first and the others are moved down. This is useful
for \code{contr.treatment} contrasts which take the first level as
the reference.\end{Description}
\begin{Usage}
\begin{verbatim}
relevel(x, ref, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] An unordered factor.
\item[\code{ref}] The reference level.
\item[\code{...}] Additional arguments for future methods.
\end{ldescription}
\end{Arguments}
\begin{Value}
A factor of the same length as \code{x}.\end{Value}
\begin{Author}\relax
B. D. Ripley\end{Author}
\begin{SeeAlso}\relax
\code{\Link{factor}}, \code{\Link{contr.treatment}}\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(warpbreaks)
warpbreaks$tension <- relevel(warpbreaks$tension, ref="M")
summary(lm(breaks ~ wool + tension, data=warpbreaks))
\end{ExampleCode}
\end{Examples}

