The function FUN is applied to f in bins specified by
xbreaks. The division of data into bins is done with cut().
Arguments
- x
a vector of numerical values.
- f
a vector of data to which
FUNwill be applied.- xbreaks
optional vector holding values of x at the boundaries between bins. If this is not given, it is computed by calling
pretty()with n=20 segments.- FUN
function that is applied to the
fvalues in each x bin. This must take a single numeric vector as input, and return a single numeric value.- include.lowest
logical value indicating whether to include
xvalues that equalxbreaks[1]. See “Details”.- ...
optional arguments to pass to
FUN.
Value
A list with the following elements: xbreaks as
used, xmids (the mid-points between those breaks) and
result (the result of applying FUN to the f values
in the designated bins).
Details
By default, the sub-intervals defined by the xbreaks argument are open
on the left and closed on the right, to match the behaviour
of cut(). An open interval does not include points on
the boundary, and so any x values that exactly match
the first breaks value will not be counted. To include
such points in the calculation, set include.lowest to TRUE.
See also
Other bin-related functions:
binApply2D(),
binAverage(),
binCount1D(),
binCount2D(),
binMean1D(),
binMean2D()
