powered by
Weighted total and mean (Horvitz-Thompson and Hajek estimators)
weighted_total(x, w, na.rm = FALSE)weighted_mean(x, w, na.rm = FALSE)
weighted_mean(x, w, na.rm = FALSE)
a numeric vector
a numeric vector of weights
a logical value indicating whether NA values should be stripped before the computation proceeds.
NA
Estimate (scalar)
-
# NOT RUN { x <- c(0.1, 0.35, 0.05, 0.1, 0.15, 0.05, 0.2) weighted_total(x, x) x <- c(0.1, 0.35, 0.05, 0.1, 0.15, 0.05, 0.2) weighted_mean(x, x) # }
Run the code above in your browser using DataLab