filter_within_range | R Documentation |
Detect outliers using the mean and standard deviation.
filter_within_range(v, cutoff)
v |
A vector with data |
cutoff |
A threshold or cutoff value that defines the range (e.g., 3) |
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.
# 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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.