\Header{nlevels}{The Number of Levels of a Factor}
\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{\Link{factor}}, \code{NA} is returned.

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

