wtd_mean: Weighted mean

Description Usage Arguments Details Value See Also Examples

View source: R/wtd_mean.R

Description

Compute the mean of x weighted by weights.

Usage

1

Arguments

x

a numerical vector.

weights

a numerical vector of weights the same length as x.

Details

If weights is NULL, all elements of x receive the same weight. Observations with zero weights are omitted before the mean is computed. Missing values are not handled specially and produce a missing value as the result.

Value

The weighted mean of x.

See Also

Other weighted statistics: wtd_median(), wtd_quantile()

Examples

1
wtd_mean(1:5, weights = 5:1)

jcpernias/ec1047 documentation built on Nov. 19, 2020, 2:33 a.m.