length<-.factor
Set Length of a factor

### Description

This function is an S3 method implementation of the length<- generic for the factor class.

### Usage

    length(x) <- value

### Arguments

x | a factor object.
value | an integer.

Value
returns an integer specifying the length of the factor; that is, the number of its elements.
Details
When a value is assigned to the length of a factor object, the factor object is shortened or lengthened to the specified length. If the factor object is lengthened, missing values are placed at the end of the resulting vector. Unlike the default implementation of length, this method retains the class and levels attribute of the factor object.
Examples

    factorA <- factor(c("a", "b", "c"))
    length(factorA) <- 5
    factorA
    # [1] a    b    c    <NA> <NA>
    # Levels: a b c
    length(factorA)
    # [1] 5
    length(factorA) <- 1
    factorA
    # [1] a
    # Levels: a b c
    length(factorA)
    # [1] 1

Package base version 6.1.5-18
Package Index