Description Usage Arguments Details Value Missing and non-finite values Author(s) See Also
Counts the number of elements in non-overlapping bins
1 2 |
x |
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.
Returns an integer
vector
of length B with non-negative integers.
Missing values in x
are ignored/dropped.
Missing values in bx
are not allowed and gives an error.
Henrik Bengtsson
An alternative for counting occurances within bins is
hist
, e.g. hist(x, breaks=bx, plot=FALSE)$counts
.
That approach is ~30-60% slower than binCounts(..., right=TRUE)
.
To count occurances 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
().
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.