binCount1D | R Documentation |
Count the number of elements of a given vector that fall within successive pairs of values within a second vector.
binCount1D(x, xbreaks, include.lowest = FALSE)
x |
vector of numerical values. |
xbreaks |
Vector of values of x at the boundaries between bins, calculated using
|
include.lowest |
logical value indicating whether to include
|
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
binCount1D(1:20, seq(0, 20, 2))$number
matches
unname(table(cut(1:20, seq(0, 20, 2))))
A list with the following elements: the breaks (xbreaks
,
midpoints (xmids
) between those breaks, and
the count (number
) of x
values between successive breaks.
Dan Kelley
Other bin-related functions:
binApply1D()
,
binApply2D()
,
binAverage()
,
binCount2D()
,
binMean1D()
,
binMean2D()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.