Fast element counting in non-overlapping bins
Counts the number of elements in non-overlapping bins
binCounts(x, idxs = NULL, bx, right = FALSE, ...)
x |
A |
idxs |
A |
bx |
A |
right |
If |
... |
Not used. |
binCounts(x, bx, right = TRUE)
gives equivalent results as
rev(binCounts(-x, bx = rev(-bx), right = FALSE))
, but is faster
and more memory efficient.
Missing values in x
are ignored/dropped. Missing values in bx
are not allowed and gives an error.
Henrik Bengtsson
An alternative for counting occurrences within bins is
hist
, e.g. hist(x, breaks = bx,
plot = FALSE)$counts
. That approach is ~30-60% slower than
binCounts(..., right = TRUE)
.
To average values within bins, see binMeans
().
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.