R: Remove the value(s) most differing from the mean
rm.outlier
R Documentation
Remove the value(s) most differing from the mean
Description
If the outlier is detected and confirmed by statistical tests, this function
can remove it or replace by sample mean or median.
Usage
rm.outlier(x, fill = FALSE, median = FALSE, opposite = FALSE)
Arguments
x
a dataset, most frequently a vector. If argument is a dataframe, then outlier is removed
from each column by sapply. The same behavior is applied by apply when the matrix
is given.
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)
Value
A dataset of the same type as argument, with outlier(s) removed or replacement by appropriate means
or medians.