Skip to contents

This function computes the *weighted arithmetic mean*.

Usage

weightedMean(x, w, i = NULL, na.rm = TRUE, ...)

Arguments

x

(named) numerical vector

w

(optional) numerical vector of weights the same length as x

i

(optional) numerical vector giving the position in x or character vector matching the names in x. If missing or i = NULL, the entire x is considered for the computation of the score

na.rm

logical, whether to remove NA values from x before computation

...

further arguments to weighted.mean

Value

A numerical value representing the computed measure. A default NA value is returned if the score can't be computed.

Details

It is a wrapper to weighted.mean function.

Author

Alessandro Barberis

Examples

x = c(1,1,2,3,3,3,NA)
w = c(1,1,8,1,1,1,1)
weightedMean(x = x, w = w, na.rm = TRUE)
#> [1] 2.076923