.bincode()When x is an integer vector, bin() is cheaper than .bincode() as
no coercion to a double vector occurs. This alternative also has more
arguments that allow you to return the start values of the binned vector,
as well as including out-of-bounds intervals.
bin(
x,
breaks,
left_closed = TRUE,
include_endpoint = FALSE,
include_oob = FALSE,
codes = TRUE
)Either an integer vector of codes indicating which bin the values fall into, or the start of the intervals for which each value falls into.
A numeric vector.
A numeric vector of breaks.
Should intervals be left-closed (and right-open)?
Default is TRUE. If FALSE they are left-open (and right-closed).
Equivalent to include.lowest in ?.bincode.
Should out-of-bounds interval be included?
Default is FALSE. This is the equivalent of adding Inf as
the last value of the breaks, or -Inf as the
first value of the breaks if left_closed = FALSE. When TRUE,
this essentially becomes findInterval().
Should an integer vector indicating which bin the values
fall into be returned? Default is TRUE. If FALSE the
start values of the respective bin intervals are returned, i.e the
corresponding breaks.
get_breaks as_discrete