weighted.sum: Compute Weighted Sum

View source: R/dthelper-computation-functions.R

weighted.sumR Documentation

Compute Weighted Sum

Description

Weights are normalised before weighted sum is computed.

Usage

weighted.sum(x, weights, na.rm = T)

Arguments

x

Input vector object

weights

weight associated to each input value of x

na.rm

If set to TRUE, NAs are ignored in computation

Value

scalar value

Examples

x <- c(1,2,3)
weights <- c(1,1,1) # equal weights
weighted.sum(x, weights)

weights <- c(5, 1, 1) # unequal weights
weight.sum(x, weights)


dennisteowh/dthelper documentation built on March 19, 2022, 11:42 a.m.