Extract.factor

0th

Percentile

Extract or Replace Parts of a Factor

Extract or replace subsets of factors.

Keywords
category
Usage
"["(x, ..., drop = FALSE) "[["(x, ...) "["(x, ...) <- value "[["(x, ...) <- value
Arguments
x
a factor
...
a specification of indices -- see Extract.
drop
logical. If true, unused levels are dropped.
value
character: a set of levels. Factor values are coerced to character.
Details

When unused levels are dropped the ordering of the remaining levels is preserved.

If value is not in levels(x), a missing value is assigned with a warning.

Any contrasts assigned to the factor are preserved unless drop = TRUE.

The [[ method supports argument exact.

Value

A factor with the same set of levels as x unless drop = TRUE.

See Also

factor, Extract.

Aliases
  • [.factor
  • [<-.factor
  • [[.factor
  • [[<-.factor
Examples
library(base) ## following example(factor) (ff <- factor(substring("statistics", 1:10, 1:10), levels = letters)) ff[, drop = TRUE] factor(letters[7:10])[2:3, drop = TRUE]
Documentation reproduced from package base, version 3.3, License: Part of R @VERSION@

Community examples

Looks like there are no examples yet.