levels {base} | R Documentation

## Levels Attributes

### Description

`levels` provides access to the levels attribute of a variable. The first form returns the value of the levels of its argument and the second sets the attribute.

The assignment form (`"levels<-"`) of `levels` is a generic function and new methods can be written for it. The most important method is that for `factor`s:

### Usage

    levels(x)
    levels(x) <- value

### See Also

`levels<-.factor`, `nlevels`.