baseLevels: Get Coarsened Factor Attributes

View source: R/coarsened.R

baseLevelsR Documentation

Get Coarsened Factor Attributes

Description

Retrieve specific attributes of a coarsened factor.

Usage

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

Arguments

x

a coarsened factor

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.

Value

The requested attribute of x.

Note

A coarsened factor has the usual attributes of a factor, but they should not be altered directly. For example, the function levels<-, the replacement version of levels, should not be used with a coarsened factor.

Author(s)

Joe Schafer Joseph.L.Schafer@census.gov

References

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

See Also

cvam, coarsened, is.naCoarsened, dropCoarseLevels

Examples

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

cvam documentation built on March 7, 2023, 5:29 p.m.