Subscript a Factor Object

DESCRIPTION:

Allows the user to extract values from a factor object through the use of subscripts.

USAGE:

x[i] 
x[i, drop=F] 
x[i] <- value 

REQUIRED ARGUMENTS:

x
an object inheriting from class "factor".
i
index for extraction or replacement; can be either numeric or logical.

OPTIONAL ARGUMENTS:

value
replacement value for the relevent piece of the factor. This can, but need not, be a factor itself. In any case, the values are interpreted in terms of the level set of the factor. Values not in the level set will generate NAs.
drop
If TRUE, the unused levels of a factor are dropped. Default is FALSE.

VALUE:

the factor formed by extracting or replacing the relevant subset.

SEE ALSO:

, .

EXAMPLES:

solder[sample(900,10), ] 

# dropping unused levels
factorA <- factor(c("ZZ", "AA", "DD", "LL", "JJ"))
levels(factorA)
levels(factorA[factorA != "DD"])
levels(factorA[factorA != "DD", drop = T])