Learn R Programming

CUFF (version 1.9)

sum.n: sum weighted on the number of non-missing values

Description

Methods that estimates a sum weighted by the number of non-missing values

Usage

# S3 method for n
sum(x,n = 1, ...)

Value

sum.n returns the values of the weighted sum.

Arguments

x

A vector of values possibly containing missing values.

n

Minimum number of valid values

...

extra parameters to sum

Author

Charles-Édouard Giguère

Details

sum(x,n) = mean(x) * length(x) / n.valid(x)

Examples

Run this code
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