\HeaderA{nlevels}{The Number of Levels of a Factor}{nlevels}
\keyword{category}{nlevels}
\begin{Description}\relax
Return the number of levels which its argument has.
\end{Description}
\begin{Usage}
\begin{verbatim}
nlevels(x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] an object, usually a factor.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If the argument is not a \code{\LinkA{factor}{factor}}, \code{NA} is returned.

The actual factor levels (if they exist) can be obtained
with the \code{\LinkA{levels}{levels}} function.
\end{Details}
\begin{Examples}
\begin{ExampleCode}
nlevels(gl(3,7)) # = 3
\end{ExampleCode}
\end{Examples}

