rm.outlier {outliers}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.

Author(s)

Lukasz Komsta

See Also

outlier

Examples

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)

[Package outliers version 0.15 Index]