Learn R Programming

SciencesPo (version 1.4.0)

WeightedMean: Computes Weighted Mean

Description

Compute the weighted mean of data.

Usage

WeightedMean(x, weights = NULL, normwt = "ignored", na.rm = TRUE)

Arguments

x
a numeric vector.
weights
a numeric vector of weights of x.
normwt
ignored at the moment.
na.rm
a logical, if TRUE, missing data will be dropped. If na.rm = FALSE, missing data will return an error.

Examples

Run this code
x <- sample(10,10)
w <- sample(5,10, replace=TRUE)

WeightedMean(x, w)

Run the code above in your browser using DataLab