dropCoarseLevels | R Documentation |
A coarsened factor, produced by the function coarsened
,
has two types of levels: base levels, to represent observations that
are fully known, and coarse levels, to represent observations that are
partially or completely missing. The function dropCoarseLevels
converts a coarsened factor to a factor or ordered factor by
removing all of the coarse levels and setting the
corresponding observations to NA
.
dropCoarseLevels(x)
x |
a factor or coarsened factor |
If the only coarse level of x
is NA
, then no information
is lost when dropCoarseLevels
is applied. If x
has
other non-empty coarse levels, then the partial information carried by
those observations is effectively discarded.
A factor or ordered factor, obtained by removing the coarse levels of
x
and setting the observations in those levels to NA
.
If x
is a factor but not a coarsened factor, then it is
returned unchanged.
Joe Schafer Joseph.L.Schafer@census.gov
For more information about coarsened factors in the cvam
package, see the vignette Understanding Coarsened Factors in cvam.
cvam
,
coarsened
,
baseLevels
,
is.naCoarsened
fac <- factor( c("red", "green", NA, "yellow", "notRed", "green") ) cFac <- coarsened( fac, levelsList = list("notRed" = c("green", "yellow")) ) dropCoarseLevels(cFac)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.