| winsorize | R Documentation |
Replaces extreme values in selected columns with the specified top and bottom quantile thresholds, rather than deleting them. This is useful for reducing the influence of outliers while preserving sample size.
winsorize(data, cols = NULL, top = 0.995, bottom = 0.0025,
group = NULL, verbose = FALSE)
data |
A data frame, matrix, or numeric vector. |
cols |
The column indices or names of selected variables. If NULL, all columns are used. |
top |
The top quantile threshold. Values above this are capped at the threshold. |
bottom |
The bottom quantile threshold. Values below this are capped at the threshold. |
group |
Optional grouping column for group-wise winsorization. |
verbose |
Logical; if |
A data frame with extreme values capped.
winsorize(data[1:100, c(1, 4, 17:19)], cols = 3:5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.