is_outlier.Rd
This function identifies outliers in a numeric vector x
.
is_outlier(x, ...)
A logical vector of the same length as x
, where TRUE
indicates that
the corresponding element in x
is an outlier.
An element is considered an outlier if it falls outside the range as defined
by boxplot.stats
from the grDevices
package. The function is useful
for quickly flagging or filtering outliers in a dataset.
# Example vector
data <- c(-10, 1, 2, 3, 4, 5, 100)
# Check for outliers
is_outlier(data)
# Using the function to filter out outliers
data[!is_outlier(data)]