rg_remove_outliers: Remove outliers from a vector based on sigma test or...

Description Usage Arguments Examples

View source: R/utilities.R

Description

This function removes outliers from a vector and replaces them with an optional value based on sigma test or the interquartile range

Usage

1
2
3
4
5
6
7
rg_remove_outliers(
  v,
  type = "iqr",
  fill = NA,
  range = ifelse(type == "iqr", 1.5, 3),
  na.rm = FALSE
)

Arguments

v

numeric vector

type

string, one of iqr for interquartile range or sigma for sigma test

fill

numeric or function, either a fixed value or a function such as mean from which the replacement values can be computed

range

numeric, this number is multiplied with the interquartile range for type = 'iqr' or the standard deviation for type = 'sigma' and determines the width of the window in which values are considered as NOT being outliers

na.rm

logical; if true, any NA and NaN's are removed from v before the quantiles, means or standard deviations are computed.

Examples

1
remove_outliers(c(1, 2, 3, 100))

sitscholl/Rgadgets documentation built on Feb. 19, 2021, 1:24 a.m.