| weighted_mean | R Documentation |
Computes the weighted mean of x using weights w, where idx is TRUE.
weighted_mean(x, w, idx)
x |
Numeric vector of values. |
w |
Numeric vector of weights, same length as |
idx |
Logical vector indicating which elements to include. |
A single numeric value. Returns NA if the sum of weights is 0.
idx_active <- c(TRUE, TRUE, FALSE, FALSE, FALSE, TRUE)
AGSA <- c(0.1, 0.2, 0.03, 0.04, 0.05, 0.6)
Duration <- c(100, 90, 80, 70, 60, 50)
ActiveIntensity <- weighted_mean(AGSA, Duration, idx_active)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.