filter_within_range: Detect outliers in data using mean and standard deviation

View source: R/utils.R

filter_within_rangeR Documentation

Detect outliers in data using mean and standard deviation

Description

Detect outliers using the mean and standard deviation.

Usage

filter_within_range(v, cutoff)

Arguments

v

A vector with data

cutoff

A threshold or cutoff value that defines the range (e.g., 3)

Value

A logical vector of the same length as 'v', where each element is 'TRUE' if the corresponding value in 'v' falls within the specified range, and 'FALSE' otherwise.

Examples

# Sample data
data <- c(10, 12, 14, 15, 20, 25, 30, 100)

# Detect values within 3 standard deviations from the mean
filter_within_range(data, cutoff = 3)

# Result:
# [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
# Explanation: All values fall within 2.5 standard deviations from the mean.

# Detect values within 1 standard deviation from the mean
filter_within_range(data, cutoff = 1)

# Result:
# [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE
# Explanation: All values except 100 fall within 1 standard deviation from the mean.


greenfeedr documentation built on April 4, 2025, 12:22 a.m.