nlevels

0th

Percentile

The Number of Levels of a Factor

Return the number of levels which its argument has.

Keywords
category
Usage
nlevels(x)
Arguments
x

an object, usually a factor.

Details

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.

Value

The length of levels(x), which is zero if x has no levels.

See Also

levels, factor.

Aliases
  • nlevels
Examples
library(base) # NOT RUN { nlevels(gl(3, 7)) # = 3 # }
Documentation reproduced from package base, version 3.6.1, License: Part of R 3.6.1

Community examples

Looks like there are no examples yet.