Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

weightedMean

Weighted mean


Description

Compute the weighted mean.

Usage

weightedMean(x, weights = NULL, na.rm = FALSE)

Arguments

x

a numeric vector.

weights

an optional numeric vector giving the sample weights.

na.rm

a logical indicating whether missing values in x should be omitted.

Details

This is a simple wrapper function calling weighted.mean if sample weights are supplied and mean otherwise.

Value

The weighted mean of values in x is returned.

Author(s)

Andreas Alfons

See Also

Examples

data(eusilc)
weightedMean(eusilc$eqIncome, eusilc$rb050)

laeken

Estimation of Indicators on Social Exclusion and Poverty

v0.5.1
GPL (>= 2)
Authors
Andreas Alfons [aut, cre], Josef Holzer [aut], Matthias Templ [aut], Alexander Haider [ctb]
Initial release
2020-02-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.