Learn R Programming

outliers (version 0.15)

outlier: Find value with largest difference from the mean

Description

Finds value with largest difference between it and sample mean, which can be an outlier.

Usage

outlier(x, opposite = FALSE, logical = FALSE)

Arguments

x

a data sample, vector in most cases. If argument is a dataframe, then outlier is calculated for each column by sapply. The same behavior is applied by apply when the matrix is given.

opposite

if set to TRUE, gives opposite value (if largest value has maximum difference from the mean, it gives smallest and vice versa)

logical

if set to TRUE, gives vector of logical values, and possible outlier position is marked by TRUE

Value

A vector of value(s) with largest difference from the mean.

See Also

rm.outlier

Examples

Run this code
# NOT RUN {
set.seed(1234)
y=rnorm(100)
outlier(y)
outlier(y,opposite=TRUE)
dim(y) <- c(20,5)
outlier(y)
outlier(y,opposite=TRUE)
# }

Run the code above in your browser using DataLab