\HeaderA{relevel}{Reorder Levels of Factor}{relevel}
\methaliasA{relevel.default}{relevel}{relevel.default}
\methaliasA{relevel.factor}{relevel}{relevel.factor}
\methaliasA{relevel.ordered}{relevel}{relevel.ordered}
\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{SeeAlso}\relax
\code{\LinkA{factor}{factor}}, \code{\LinkA{contr.treatment}{contr.treatment}},
\code{\LinkA{levels}{levels}}, \code{\LinkA{reorder}{reorder}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
warpbreaks$tension <- relevel(warpbreaks$tension, ref="M")
summary(lm(breaks ~ wool + tension, data=warpbreaks))
\end{ExampleCode}
\end{Examples}

