NLEVELS

NLEVELS(f) gives the number of levels of factor f.