bin: An integer vector with values from 1L to nbins
w: Weights per entry in bin.
nbins: Number of bins
Returns
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).
Examples
weighted_tabulate(c(1,1,2))weighted_tabulate(c(1,1,2), nbins =3L)weighted_tabulate(c(1,1,2), w = c(0.5,0.5,1), nbins =3L)
See Also
Other weighted statistics: weighted_moments(), weighted_quantile()