wtd_mean: Compute weighted mean.

wtd_meanR Documentation

Compute weighted mean.

Description

Compute weighted mean.

Usage

wtd_mean(x, weights = NULL, na.rm = TRUE)

Arguments

x

A numeric vector.

weights

A numeric vector of weights.

na.rm

Set to FALSE to suppress checking for NAs

Value

Returns scalar vector of length one.

Examples

## Not run: set.seed(1)
         x <- runif(500)
         wts <- sample(1:6, 500, TRUE)
         mn <- wtd_mean(x = x, weights = wts)
## End(Not run)


gerasy1987/usefulr documentation built on Sept. 18, 2024, 9:46 a.m.