\Header{levels.factor}{Factor Levels Assignment}
\alias{levels<\Rdash.factor}{levels.factor}
\keyword{category}{levels.factor}
\begin{Description}\relax
\code{levels<-} provides a way to alter the levels attribute of factor.
\code{value} can be a vector of character strings with length equal to
the number of levels of \code{x}, or a named list specifying how to
rename the levels.\end{Description}
\begin{Usage}
\begin{verbatim}
levels(x) <- value
\end{verbatim}
\end{Usage}
\begin{SeeAlso}\relax
\code{\Link{factor}}, \code{\Link{levels}},
\code{\Link{levels<\Rdash}}, \code{\Link{nlevels}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# assign individual levels
x <- gl(2, 4, 8)
levels(x)[1] <- "low"
levels(x)[2] <- "high"

# or as a group
y <- gl(2, 4, 8)
levels(y) <- c("low", "high")

# combine some levels
z <- gl(3, 2, 12)
levels(z) <- c("A", "B", "A")

# same, using a named list
z <- gl(3, 2, 12)
levels(z) <- list(A=c(1,3), B=2)
\end{ExampleCode}
\end{Examples}

