Learn R Programming

laeken (version 0.4.6)

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.

Value

The weighted mean of values in x is returned.

Details

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

See Also

incMean

Examples

Run this code
# NOT RUN {
data(eusilc)
weightedMean(eusilc$eqIncome, eusilc$rb050)
# }

Run the code above in your browser using DataLab