Skip to contents

This function removes outliers from a specified column of a data frame using a robust threshold based on the Median Absolute Deviation (MAD). Values outside the interval median ± 3 * MAD are excluded. The method is resistant to extreme values and does not assume normality.

Usage

B_remove_outlier(B, col, k = 5)

Arguments

B

A data frame containing the data to be filtered.

col

A character string specifying the column name in B on which outlier removal should be performed.

Value

A filtered data frame with outliers removed from the specified column.

Details

The MAD-based rule is a robust alternative to standard deviation filtering. It is particularly suitable for skewed or heavy-tailed distributions, where traditional z-score filtering may fail. If the column contains no variability (MAD = 0), the function will return the original data frame.

Examples

df <- data.frame(value = c(1, 2, 3, 100))
B_remove_outlier(df, "value")
#> [1] 1 2 3