Computes the sum of w grouped by bin.
If w is missing the result is equivalent to
tabulate(bin, nbins)
Usage
weighted_tabulate(bin, w, nbins = max(1L, bin, na.rm = TRUE))Arguments
- bin
An integer vector with values from
1Ltonbins- w
Weights per entry in
bin.- nbins
Number of bins
Value
A vector with length nbins where the ith result is equal to
sum(w[bin == i]) or sum(bin == i) if w is missing.
For integer weights, this is equivalent to tabulate(rep(bin, w), nbins).
See also
Other weighted statistics:
weighted_moments(),
weighted_quantile()