rm.outlier | 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
outlier
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.