Computes the sample means in non-overlapping bins
binMeans(y, x, idxs = NULL, bx, na.rm = TRUE, count = TRUE,
right = FALSE, ...)A numeric or logical
vector of K values to calculate means on.
A vector indicating subset of elements to
operate over. If NULL, no subsetting is done.
A numeric vector of B + 1
ordered positions specifying the B > 0 bins [bx[1], bx[2]),
[bx[2], bx[3]), ..., [bx[B], bx[B + 1]).
If TRUE, missing values in y
are dropped before calculating the mean, otherwise not.
If TRUE, the number of data points
in each bins is returned as attribute count, which is an
integer vector of length B.
If TRUE, the bins are right-closed
(left open), otherwise left-closed (right open).
Not used.
binMeans(x, bx, right = TRUE) gives equivalent results as
rev(binMeans(-x, bx = sort(-bx), right = FALSE)), but is faster.
Data points where either of y and x is missing are dropped
(and therefore are also not counted). Non-finite values in y are
not allowed and gives an error. Missing values in bx are not allowed
and gives an error.
[1] R-devel thread Fastest non-overlapping binning mean
function out there? on Oct 3, 2012