getCat {simPop} | R Documentation |
Categorize (semi-)continuous variables
Description
Categorize continuous or semi-continuous variables. This is a utility
function that is useful for writing custom wrapper functions such as
simEUSILC
.
Usage
getCat(x, breaks, zeros = TRUE, right = FALSE)
Arguments
x |
a numeric vector to be categorized. |
breaks |
a numeric vector of two or more break points. |
zeros |
a logical indicating whether |
right |
logical; if |
Details
If zeros
is TRUE
, 0 is added to the break points and treated
as its own factor level. Consequently, intervals for negative values are
left-closed and right-open, whereas intervals for positive values are
left-open and right-closed.
Value
A factor
containing the categories.
Author(s)
Andreas Alfons
See Also
Examples
data(eusilcS)
## semi-continuous variable
breaks <- getBreaks(eusilcS$netIncome,
weights=eusilcS$rb050, equidist = FALSE)
netIncomeCat <- getCat(eusilcS$netIncome, breaks)
summary(netIncomeCat)