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

outliers

Identify outliers in a variable


Description

Takes in a vector, and returns count and index of outliers

Usage

outliers(vector)

Arguments

vector

an integer or numeric vector

Details

The function uses the same criteria to identify outliers as the one used for box plots. All values that are greater than 75th percentile value + 1.5 times the inter quartile range or lesser than 25th percentile value - 1.5 times the inter quartile range, are tagged as outliers.

The individual elements (number of outliers and index of outliers) of the two element output list can be picked using the code given in example. The index of outliers can be used to get a vector of all outliers.

Value

a list with two elements: count and index of outliers

Author(s)

Akash Jain

See Also

Examples

# Scores vector
scores <- c(1, 4, 7, 10, 566, 21, 25, 27, 32, 35,
            49, 60, 75, 23, 45, 86, 26, 38, 34, 223, -3)

# Identify the count of outliers and their index
ltOutliers <- outliers(vector = scores)
numOutliers <- ltOutliers$numOutliers
idxOutliers <- ltOutliers$idxOutliers
valOutliers <- scores[idxOutliers]

StatMeasures

Easy Data Manipulation, Data Quality and Statistical Checks

v1.0
GPL-2
Authors
Akash Jain
Initial release
2015-03-24

We don't support your browser anymore

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