winsorize | R Documentation |
Replace extreme values by absolute or quantile threshold
winsorize(
x,
lo = NULL,
hi = NULL,
prob.lo = 0.025,
prob.hi = 0.975,
quantile.type = 7,
verbose = TRUE
)
x |
Numeric vector: Input data |
lo |
Numeric: If not NULL, replace any values in |
hi |
Numeric: If not NULL, replace any values in |
prob.lo |
Numeric (0, 1): If not NULL and |
prob.hi |
Numeric (0, 1): If not NULL and |
quantile.type |
Integer: passed to |
verbose |
Logical: If TRUE, print messages to console. |
If both lo and prob.lo or both hi and prob.hi are NULL, cut-off is set to min(x) and max(x) respectively, i.e. no values are changed
E.D. Gennatas
# Winsorize a normally distributed variable
x <- rnorm(500)
xw <- winsorize(x)
# Winsorize an exponentially distributed variable only on
# the top 5% highest values
x <- rexp(500)
xw <- winsorize(x, prob.lo = NULL, prob.hi = .95)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.