Learn R Programming

COINr (version 1.1.14)

a_gmean: Weighted geometric mean

Description

Weighted geometric mean of a vector. NA are skipped by default.

Usage

a_gmean(x, w = NULL)

Value

The geometric mean, as a numeric value.

Arguments

x

A numeric vector of positive values.

w

A vector of weights, which should have length equal to length(x). Weights are relative and will be re-scaled to sum to 1. If w is not specified, defaults to equal weights.

Details

This function replaces the now-defunct geoMean() from COINr < v1.0.

Examples

Run this code
# a vector of values
x <- 1:10
# a vector of weights
w <- runif(10)
# weighted geometric mean
a_gmean(x,w)

Run the code above in your browser using DataLab