Skip to contents

weighted.tabulate() returns the sum of weights for each integer in the vector bin.

Usage

weighted.tabulate(bin, w = NULL, nbins = max(1L, bin, na.rm = TRUE))

Arguments

bin

a numeric vector of positive integers, or a factor.

w

a numeric vector of the sample weights for each value in bin.

nbins

the number of bins to be used.

Value

weighted.tabulate() returns an numeric vector.

Details

weighted.tabulate() is a wrapper function of tabulate() to reflect sample weights.

Examples

tabulate(bin = c(2, 2, 3, 5))
#> [1] 0 2 1 0 1
weighted.tabulate(bin = c(2, 2, 3, 5), w = 1:4)
#> [1] 0 3 3 0 4