Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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 class 'n'
sum(x,n = 1, ...)

Arguments

x

A vector of values possibly containing missing values.

n

Minimum number of valid values

...

extra parameters to sum

Details

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

Value

sum.n returns the values of the weighted sum.

Author(s)

Charles-Édouard Giguère

Examples

sum.n(c(1, 2, NA, NA), n = 2)
### [1] 6
sum.n(c(1, NA, NA, NA), n = 2)
### [1] NA

CUFF

Charles's Utility Function using Formula

v1.7
GPL (>= 2)
Authors
Charles-Édouard Giguère
Initial release
2020-09-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.