Bins a numeric vector x
into bins specified by breaks
.
Values outside the range of breaks
will be placed in the lowest or highest bin.
Set labels = FALSE
to return integer codes only, and explicit_na = TRUE
for
maximal synergy with the "collapse" package.
Uses the logic of spatstat.utils::fastFindInterval()
for equi-length bins.
fcut(x, breaks, labels = NULL, right = TRUE, explicit_na = FALSE)
A numeric vector.
A monotonically increasing numeric vector of breaks.
A character vector of length length(breaks) - 1
with bin labels.
By default (NULL
), the levels c("1", "2", ...)
are used. Set to FALSE
to return raw integer codes.
Right closed bins (TRUE
, default) or not?
If TRUE
, missing values are encoded by the bin value
length(breaks)
, having NA
as corresponding factor level. The factor will get
the additional class "na.included".
Binned version of x
. Either a factor, or integer codes.