baseLevels | R Documentation |
Retrieve specific attributes of a coarsened factor.
baseLevels(x) nBaseLevels(x) coarseLevels(x) nCoarseLevels(x) mapping(x)
x |
a coarsened factor |
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.
The requested attribute of x
.
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.
Joe Schafer Joseph.L.Schafer@census.gov
For more information, refer to the package vignette Understanding Coarsened Factors in cvam.
cvam
,
coarsened
,
is.naCoarsened
,
dropCoarseLevels
fac <- factor( c("red", "green", NA, "yellow", "notRed", "green") ) cFac <- coarsened( fac, levelsList = list("notRed" = c("green", "yellow")) ) baseLevels(cFac) mapping(cFac)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.