Learn R Programming

RVAideMemoire (version 0.9-83-7)

wmean: Weighted arithmetic mean

Description

Computes the weighted arithmetic mean of a vector.

Usage

wmean(x, w = rep(1, length(x)), na.rm = TRUE)

Arguments

x

numeric vector.

w

numeric vector of weights.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

Author

Maxime HERVE <maxime.herve@univ-rennes1.fr>

Examples

Run this code
mean(1:10)
wmean(1:10,w=10:1)

Run the code above in your browser using DataLab