powered by
Return the number of levels which its argument has.
nlevels(x)
an object, usually a factor.
The length of levels(x), which is zero if x has no levels.
levels(x)
x
This is usually applied to a factor, but other objects can have levels.
The actual factor levels (if they exist) can be obtained with the levels function.
levels
levels, factor.
factor
nlevels(gl(3, 7)) # = 3
Run the code above in your browser using DataLab