Weighted mean that allows NA in values and weights

wtd_mean(x, w, na.rm = TRUE)

Arguments

x

values whose weighted mean is to be computed

w

weights of the same length as x to be used against x

na.rm

a logical values indicating whether NA values in both x and w should be stripped before computation