Get and set the zero bin manually
getZeroBin(bins)
setZeroBin(bins, zeroBin)
Factor, typically the return value of
bin
.
Numeric or character scalar indicating the level to use as the zero bin, or NA.
For getZeroBin
, the index of the level representing the zero bin.
For setZeroBin
, a modified factor with the zero bin set to the
provided value.
set.seed(1)
x <- rnorm(100)
bins <- bin(x, "equalN", nElements = 10, minAbsX = 0.5)
#> Warning: Zero-bin breaks (-0.621,0.576] have been adjusted by more than 20% compared to `minAbsX` to best respect `binmode`.
#> Please use `bin(..., binmode = "breaks", breaks = X)` and optionally `setZeroBin(...)` to enforce breaks as defined by `X`.
getZeroBin(bins)
#> [1] 3
bins <- setZeroBin(bins, 2)