rm.outlier {outliers} | R Documentation |
If the outlier is detected and confirmed by statistical tests, this function can remove it or replace by sample mean or median.
rm.outlier(x, fill = FALSE, median = FALSE, opposite = FALSE)
x |
a dataset, most frequently a vector. If argument is a dataframe, then outlier is removed
from each column by |
fill |
If set to TRUE, the median or mean is placed instead of outlier. Otherwise, the outlier(s) is/are simply removed. |
median |
If set to TRUE, median is used instead of mean in outlier replacement. |
opposite |
if set to TRUE, gives opposite value (if largest value has maximum difference from the mean, it gives smallest and vice versa) |
A dataset of the same type as argument, with outlier(s) removed or replacement by appropriate means or medians.
Lukasz Komsta
set.seed(1234)
y=rnorm(100)
outlier(y)
outlier(y,opposite=TRUE)
rm.outlier(y)
rm.outlier(y,opposite=TRUE)
dim(y) <- c(20,5)
outlier(y)
outlier(y,logical=TRUE)
outlier(y,logical=TRUE,opposite=TRUE)
rm.outlier(y)
rm.outlier(y,opposite=TRUE)