R/winsor.R

Defines functions winsor

Documented in winsor

##' Winsorising a vector: any value higher(lower) than 'u'('l') are changed to 'u'('l').
##' @title Winsorize a vector
##' @param x the input to winsorize.
##' @param u the highest value desired.
##' @param l the lowest value desired.
##' @return a vector with winsorized values.
##' @author Jean Monlong
##' @keywords internal
winsor <- function(x, u = 5, l = NULL) {
    if (!is.null(u) & any(x > u)) {
        x[x > u] = u
    }
    if (!is.null(l) & any(x > l)) {
        x[x < l] = l
    }
    return(x)
} 
jmonlong/PopSV documentation built on Sept. 1, 2018, 12:04 p.m.