binCounts: Fast element counting in non-overlapping bins
Description
Counts the number of elements in non-overlapping binsUsage
## S3 method for class 'default':
binCounts(x, bx, ...)
Arguments
bx
A numeric
vector
of B+1 ordered positions specifying
the B bins [bx[1],bx[2])
, [bx[2],bx[3])
, ...,
[bx[B],bx
Value
- Returns an
integer
vector
of length B with non-negative integers.
Missing and non-finite values
Missing values in x
are ignored/dropped.
Missing values in bx
are not allowed and gives an error.See Also
Note that hist
is almost as fast for counting
occurances within bins, e.g.
hist(x, breaks=bx, right=FALSE, plot=FALSE)$counts
. To average values within bins, see binMeans
().