a_amean: Weighted arithmetic mean

View source: R/aggregate.R

a_ameanR Documentation

Weighted arithmetic mean

Description

The vector of weights w is relative since the formula is:

Usage

a_amean(x, w)

Arguments

x

A numeric vector.

w

A vector of numeric weights of the same length as x.

Details

y = \frac{1}{\sum w_i} \sum w_i x_i

If x contains NAs, these x values and the corresponding w values are removed before applying the formula above.

Value

The weighted mean as a scalar value

Examples

x <- c(1:10)
w <- c(10:1)
a_amean(x,w)


COINr documentation built on May 29, 2024, 1:18 a.m.