powered by
nlevels(x)
levels(x)
x
The actual factor levels (if they exist) can be obtained with the levels function.
levels
factor
nlevels(gl(3, 7)) # = 3
Run the code above in your browser using DataLab