weighted.mean: Weighted Mean

Description Usage Arguments Details

View source: R/analysisFunctions.R

Description

Returns a weighted mean given a vector and weights.

Usage

1
weighted.mean(x, w = NULL, xLoc = 2, wLoc = 3, na.rm = FALSE)

Arguments

x

a numeric vector. Alternatively, x can be a matrix-like object that includes data for the vector and the weights.

w

a numeric vector of weights.

xLoc

if x is matrix-like, this specifies the column containing vector information. Can be the column number or name.

wLoc

if x is matrix-like, this specifies the column containing weight information. Can be the column number or name.

na.rm

if True, remove NA's from data. Default is False

Details

For 'tapply' or 'by' compatibility, the function can take a matrix or data frame as long as the vector and weight column locations are specified.


mnblonsky/REMI documentation built on May 22, 2017, 11:57 a.m.