Learn R Programming

MetricsWeighted (version 0.1.0)

weighted_mean: Weighted mean that handles NULL weights

Description

Returns weighted mean of numeric vector.

Usage

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

Arguments

x

Numeric vector.

w

Optional case weights.

...

Further arguments passed to weighted_mean.

Value

A length-one numeric vector.

Examples

Run this code
# NOT RUN {
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