## S3 method for class 'default':
binCounts(x, bx, right=FALSE, ...)
TRUE
, the bins are right-closed (left open),
otherwise left-closed (right open).x
are ignored/dropped.
Missing values in bx
are not allowed and gives an error.binCounts(x, bx, right=TRUE)
gives equivalent results as
rev(binCounts(-x, bx=rev(-bx), right=FALSE))
, but is
faster and more memory efficient.hist
, e.g. hist(x, breaks=bx, plot=FALSE)$counts
.
That approach is ~30-60% slower than binCounts(..., right=TRUE)
. To count occurrences of indices x
(positive integer
s) in
[1,B]
, use tabulate(x, nbins=B)
, where x
does
not have to be sorted first.
For details, see tabulate
().
To average values within bins, see binMeans
().