outliers: Identify outliers in a variable

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/outliers.R

Description

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

Usage

1

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

decile, pentile, imputemiss

Examples

1
2
3
4
5
6
7
8
9
# 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]

Example output



StatMeasures documentation built on May 2, 2019, 1:44 p.m.