Extract.factor: Extract or Replace Parts of a Factor

Description Usage Arguments Details Value See Also Examples

Description

Extract or replace subsets of factors.

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'factor'
x[..., drop = FALSE]
## S3 method for class 'factor'
x[[...]]
## S3 replacement method for class 'factor'
x[...] <- value
## S3 replacement method for class 'factor'
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.

Examples

1
2
3
4
## following example(factor)
(ff <- factor(substring("statistics", 1:10, 1:10), levels = letters))
ff[, drop = TRUE]
factor(letters[7:10])[2:3, drop = TRUE]

robertzk/monadicbase documentation built on May 27, 2019, 10:35 a.m.