Levels Attributes

Usage

levels(x)
levels(x) <- value

Arguments

x

an object, for example a factor.

value

A valid value for levels(x).
For the default method, NULL or a character vector. For the
factor method, a vector of character strings with length at
least the number of levels of x, or a named list specifying how to
rename the levels.

Details

Both the extractor and replacement forms are generic and new methods
can be written for them. The most important method for the replacement
function is that for factors.

For the factor replacement method, a NA in value
causes that level to be removed from the levels and the elements
formerly with that level to be replaced by NA.

Note that for a factor, replacing the levels via
levels(x) <- value is not the same as (and is preferred to)
attr(x, "levels") <- value.