Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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.

Author(s)

Lukasz Komsta, corrections by Markus Graube

See Also

Examples

set.seed(1234)
y=rnorm(100)
outlier(y)
outlier(y,opposite=TRUE)
dim(y) <- c(20,5)
outlier(y)
outlier(y,opposite=TRUE)

outliers

Tests for outliers

v0.14
GPL (>= 2)
Authors
Lukasz Komsta <lukasz.komsta@umlub.pl>
Initial release
2011-01-23

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.