powered by
Methods that estimates a sum weighted by the number of non-missing values
# S3 method for n sum(x,n = 1, ...)
sum.n returns the values of the weighted sum.
A vector of values possibly containing missing values.
Minimum number of valid values
extra parameters to sum
Charles-Édouard Giguère
sum(x,n) = mean(x) * length(x) / n.valid(x)
sum.n(c(1, 2, NA, NA), n = 2) ### [1] 6 sum.n(c(1, NA, NA, NA), n = 2) ### [1] NA
Run the code above in your browser using DataLab