inst/resources/scripts/wmean.r

# program spuRs/resources/scripts/wmean.r

wmean <- function(x, k) {
    # calculate the k-th Windsorised mean of the vector x
    x <- sort(x)
    n <- length(x)
    x[1:k] <- x[k+1]
    x[(n-k+1):n] <- x[n-k]
    return(mean(x))
}

Try the spuRs package in your browser

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

spuRs documentation built on May 2, 2019, 12:44 p.m.