Removes outliers based on their distance from the inter-quartile range (IQR). Excludes all points beyond coef times the IQR. The function uses the command boxplot.stats() which uses the Tukey's method to identify the outliers ranged above and below the coef*IQR.

remove_outliers(vec, coef = 1.5)

Arguments

vec

A vector of numeric values

coef

A number specifying the maximum distance from the inter-quartile range of vec for which values in vec are not replaced with NA.

Value

A vector of numeric values of length length(vec) with all elements identical as in vec except that outliers are replaced by NA.

Examples

if (FALSE) { # \dontrun{
vec <- remove_outliers( vec, coef=3 ) 
} # }