View source: R/dthelper-computation-functions.R
weighted.sum | R Documentation |
Weights are normalised before weighted sum is computed.
weighted.sum(x, weights, na.rm = T)
x |
Input vector object |
weights |
weight associated to each input value of x |
na.rm |
If set to TRUE, NAs are ignored in computation |
scalar value
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.