Levels Attribute

DESCRIPTION:

Returns levels of an object. This is most useful for factors and bdFactors.

USAGE:

levels(x) 
levels(x) <- value 

REQUIRED ARGUMENTS:

x
any object. Typically a factor.

OPTIONAL ARGUMENTS:

value
vector of character strings or bdCharacter.

VALUE:

if x has levels, then the levels are returned; otherwise NULL.

SIDE EFFECTS:

if an assignment is made to the levels of an object, then the levels (labels) are changed.

DETAILS:

Using levels<- makes sure that the length of value is the same as the length of the (old) levels of x, but you can combine factors by giving them the same level.

If value is a list and x is a factor, the method returns merge.levels(x, value). See merge.levels for details on how this may be used to combine or add levels to a factor.

SEE ALSO:

, , , , , .

EXAMPLES:

levels(fuel.frame$Type[1:9])
#demonstrates drop
levels(fuel.frame$Type[1:9, drop=TRUE])