is_outlier: Check for outliers in a numeric vector

View source: R/i.R

is_outlierR Documentation

Check for outliers in a numeric vector

Description

This function identifies outliers in a numeric vector x.

Usage

is_outlier(x, ...)

Arguments

x

A numeric vector for which outliers need to be identified.

...

Additional arguments passed to boxplot.stats.

Details

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.

Value

A logical vector of the same length as x, where TRUE indicates that the corresponding element in x is an outlier.

Examples

# 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)]


theMILOlab/SPATA2 documentation built on Feb. 8, 2025, 11:41 p.m.