Learn R Programming

MetricsWeighted (version 0.5.4)

weighted_mean: Weighted Mean

Description

Returns weighted mean of a numeric vector. In contrast to stats::weighted.mean, w does not need to be specified.

Usage

weighted_mean(x, w = NULL, ...)

Value

A length-one numeric vector.

Arguments

x

Numeric vector.

w

Optional non-negative, non-missing case weights.

...

Further arguments passed to mean or weighted.mean.

See Also

weighted_quantile.

Examples

Run this code
weighted_mean(1:10)
weighted_mean(1:10, w = NULL)
weighted_mean(1:10, w = 1:10)

Run the code above in your browser using DataLab