Learn R Programming

daltoolbox (version 1.2.747)

outliers_boxplot: Outlier removal by boxplot (IQR rule)

Description

Removes outliers from numeric columns using Tukey's boxplot rule: values below Q1 - alpha·IQR or above Q3 + alpha·IQR are flagged as outliers.

Usage

outliers_boxplot(alpha = 1.5)

Value

returns an outlier object

Arguments

alpha

boxplot outlier threshold (default 1.5, but can be 3.0 to remove extreme values)

Details

The default alpha=1.5 corresponds to the standard boxplot whiskers; alpha=3 is used for extreme outliers.

References

Tukey, J. W. (1977). Exploratory Data Analysis. Addison‑Wesley.

Examples

Run this code
# code for outlier removal
out_obj <- outliers_boxplot() # class for outlier analysis
out_obj <- fit(out_obj, iris) # computing boundaries
iris.clean <- transform(out_obj, iris) # returning cleaned dataset

#inspection of cleaned dataset
nrow(iris.clean)

idx <- attr(iris.clean, "idx")
table(idx)
iris.outliers_boxplot <- iris[idx,]
iris.outliers_boxplot

Run the code above in your browser using DataLab