R/wtd.mean.R

`wtd.mean` <-
function (x, weights = NULL, normwt = "ignored", na.rm = TRUE) 
{
    if (!length(weights)) 
        return(mean(x, na.rm = na.rm))
    if (na.rm) {
        s <- !is.na(x + weights)
        x <- x[s]
        weights <- weights[s]
    }
    sum(weights * x)/sum(weights)
}

Try the rgrs package in your browser

Any scripts or data that you put into this service are public.

rgrs documentation built on May 2, 2019, 4:54 p.m.