This help topic is for R version 1.1. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/nlevels.html
nlevels {base}R Documentation

The Number of Levels of a Factor

Description

Return the number of levels which its argument has.

If the argument is not a factor, NA is returned.

The actual factor levels (if they exist) can be obtained with the levels function. nlevels(gl(3,7)) # = 3 category

Usage

nlevels(x)

[Package base version 1.1 ]