Learn R Programming

cvam (version 0.9.3)

baseLevels: Get Coarsened Factor Attributes

Description

Retrieve specific attributes of a coarsened factor.

Usage

baseLevels(x)
nBaseLevels(x)
coarseLevels(x)
nCoarseLevels(x)
mapping(x)

Value

The requested attribute of x.

Arguments

x

a coarsened factor

Author

Joe Schafer Joseph.L.Schafer@census.gov

Details

A coarsened factor, produced by the function coarsened, is an extended type of factor whose elements may be fully observed, partially observed, or missing. The full set of attributes of a coarsened factor may be obtained by attributes, and individual attributes are available with attr. The functions documented on this page are convenient alternatives to attr.

The elements of baseLevels, a character vector of length nBaseLevels, represent states of complete knowledge. The elements of coarseLevels, a character vector of length nCoarseLevels, represent states of incomplete or missing information. Each element of coarseLevels maps onto two or more elements of baseLevels. The attribute mapping is an integer matrix with nCoarseLevels rows and nBaseLevels columns, with 1 in position [i,j] if coarse level i contains base level j. The last coarse level is always NA, and it contains every base level.

References

For more information, refer to the package vignette Understanding Coarsened Factors in cvam.

See Also

cvam, coarsened, is.naCoarsened, dropCoarseLevels

Examples

Run this code
fac <- factor( c("red", "green", NA, "yellow", "notRed", "green") )
cFac <- coarsened( fac,
   levelsList = list("notRed" = c("green", "yellow")) )
baseLevels(cFac)
mapping(cFac)

Run the code above in your browser using DataLab