nlevels {base} | R Documentation |
Return the number of levels which its argument has.
nlevels(x)
x |
an object, usually a factor. |
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