Skip to contents

Outlier detection based on Median Absolute Deviation (MAD) for asymetric distributions and interquartile range. The function calculates the distance to the median for every value in the distribution relative to the left or right side MAD. It then compares the value to your threshold and labels the outliers.

Usage

outlier_range(x, zero_mad_action = NULL, threshold = 3.5, percent = TRUE)

Arguments

x

A vector of numeric values.

zero_mad_action

Determines the action in the event of an MAD of zero. Defaults to NULL. The options are:

  • NULL: process runs with no warning

  • "warn": a warning will be displayed

  • "stop": process is stopped

threshold

Z-score threshold (defaults to 3.5).

percent

Indicator for the scale of the data. If function is run for percantage data, the lower limit will not be negative while the upper limit does not exceed 100 percent. Defaults to TRUE.

Value

A data.frame with numeric range.

Examples


x <- c(1, 2, 3, 3, 4, 4, 4, 5, 5.5, 6, 6, 6.5, 7, 7, 7.5, 8, 9, 12, 52, 90)

outlier_range(x)
#>   median   iqr lower upper  label
#> 1      6 3.625     0    13 0 - 13