Identify outliers in a variable
Takes in a vector, and returns count and index of outliers
outliers(vector)
vector |
an integer or numeric vector |
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.
a list with two elements: count and index of outliers
Akash Jain
# 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]
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.