Count the number of elements of a given vector that fall within successive pairs of values within a second vector.
Arguments
- x
vector of numerical values.
- xbreaks
Vector of values of x at the boundaries between bins, calculated using
pretty()
if not supplied.- include.lowest
logical value indicating whether to include
x
values that equalxbreaks[1]
. See “Details”.
Value
A list with the following elements: the breaks (xbreaks
,
midpoints (xmids
) between those breaks, and
the count (number
) of x
values between successive breaks.
Details
By default, the sub-intervals defined by the xbreaks
argument are open
on the left and closed on the right, to match the behaviour
of cut()
. An open interval does not include points on
the boundary, and so any x
values that exactly match
the first breaks
value will not be counted. To count such
points, set include.lowest
to TRUE.
To contextualize binCount1D()
in terms of base R functions,
note that
matches
See also
Other bin-related functions:
binApply1D()
,
binApply2D()
,
binAverage()
,
binCount2D()
,
binMean1D()
,
binMean2D()