removeOLs | R Documentation |
Outliers are defined as values deviating more than X standard deviations (SDs) from the mean.
removeOLs(.tbl, olvars = NULL, groups = NULL, s = 3, make.na = FALSE)
.tbl |
A |
olvars |
Names or numeric index of the variables to detect outliers in.
If |
groups |
(optional) name or numeric index of the variable identifying groups of observations; outlier detection will be performed separately per group. |
s |
If a value deviates more SDs from the mean than this value, it is marked as an outlier |
make.na |
If |
This does not detect any outliers in groups with less than 3 non-NA observations.
The input data.frame
or matrix with outliers excluded.
Sercan Kahveci
[vec.removeOLs()] for the same outlier exclusion applied to a single vector.
# Standard deviation limits can be set with argument s
removeOLs(mtcars, olvars=c("mpg", "disp", "hp"))
removeOLs(mtcars, olvars=c("mpg", "disp", "hp"), s=1)
# Replace OLs with NA with argument make.na
testdata <- mtcars
testdata$mpg[1] <- 40
testdata$hp[2] <- 500
removeOLs(testdata, olvars=c("mpg", "disp", "hp"), groups="vs", make.na=TRUE)
# Also works on matrices
testmat <- matrix(rnorm(1000), ncol=5)
testmat[cbind(sample(1:200,5),1:5)]<-1000
removeOLs(testmat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.