## 'x' is rvec, 'wt' is ordinary vector
v <- rvec(list(c(1, 11),
c(2, 12),
c(7, 17)))
weights <- c(40, 80, 72)
weighted_mean(v, wt = weights)
## 'x' is ordinary vector, 'wt' is rvec
y <- c(1, 2, 3)
w <- rvec(list(c(100, 200),
c(210, 889),
c(200, 200)))
weighted_mean(y, wt = w)
weighted_mean(y, wt = w, na_rm = TRUE)
Run the code above in your browser using DataLab