Description Usage Arguments Details Value Examples
View source: R/treat_outliers.R
Treats numerical outliers either by winsorizing or by truncating.
1 
x 
Data that is coercible into a numeric vector or matrix. If it is a data frame then all numerical variables of the data frame are coerced into a matrix. 
percentile 
A numeric scalar.
The percentile below which observations
are considered to be outliers. Is treated symmetrical so that

truncate 
A logical scalar. If TRUE then data are truncated (i.e., set to NA if out of bounds). Defaults to FALSE. 
by 
NULL or either a factor vector or a character string
identifying a factor variable in the data frame provided by x.
The factor indicated by 'by' is being used to identify groups
by which the outlier treatment is applied. Defaults to NULL (no grouping).
If provided, the resulting vector must not contain NAs and needs to be such so that

... 
Additional parameters forwarded to quantile (notably, 
All members of the numerical matrix are checked for finiteness and are set to NA if they are not finite. NAs are removed when calculating the outlier cutoffs.
A numeric vector or matrix containing the outliertreated x
.
if a data frame was provided in x
, a data frame with its numeric variables
replaced by their outliertreated values.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  treat_outliers(seq(1:100), 0.05)
treat_outliers(seq(1:100), truncate = TRUE, 0.05)
# When you like the percentiles calculated like STATA's summary or pctile:
treat_outliers(seq(1:100), 0.05, type = 2)
df < data.frame(a = seq(1:1000), b = rnorm(1000), c = sample(LETTERS[1:5], 1000, replace=TRUE))
winsorized_df < treat_outliers(df)
summary(df)
summary(winsorized_df)
winsorized_df < treat_outliers(df, 0.05, by="c")
by(df, df$c, summary)
by(winsorized_df, df$c, summary)
hist(treat_outliers(rnorm(1000)), breaks=100)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.