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
levels, factor.
Examples
fa <- factor(c("a", "b", "c", "b", "a"))
nlevels(fa)
# [1] 3
Package base version 6.0.0-69
Package Index