nlevels
Number of Levels of a factor Object
Description
Returns the number of levels for the specified object.
Usage
nlevels(x)
Arguments
x |
an object, typically a factor, having a levels attribute.
|
Value
an integer value giving the number of levels. Returns 0 if no levels exist.
See Also
Examples
fa <- factor(c("a", "b", "c", "b", "a"))
nlevels(fa)
# [1] 3