outliersZ is used to identify outliers in vectors using Z-score cut-off

outliersZ(x, zCutOff = 1.96, replaceOutliersWith = NA,
outlierIndices = FALSE, showZValues = FALSE, digits = 2)

Arguments

x

a vector of numbers

zCutOff

value to use as cutoff (1.96 is a common value)

replaceOutliersWith

if value is an outlier, what to replace it with? NA by default

outlierIndices

return index/position of outlier

showZValues

if TRUE, will show z score of each value

digits

how many digits/decimals to round output to

Value

A vector with outliers identified (default converts outliers to NA)

Note

This detection method is not as robust as the median absolute deviation outlier detection method.

See also

Author

Hause Lin

Examples

example <- c(1, 3, 3, 6, 8, 10, 10, 1000) # 1000 is an outlier outliersZ(example)
#> 1 outliers detected.
#> Outliers replaced with NA
#> [1] 1 3 3 6 8 10 10 NA
outliersZ(example, zCutOff = 3.0)
#> 0 outliers detected.
#> Outliers replaced with NA
#> [1] 1 3 3 6 8 10 10 1000
outliersZ(example, zCutOff = 1.0, replaceOutliersWith = -999)
#> 1 outliers detected.
#> Outliers replaced with -999
#> [1] 1 3 3 6 8 10 10 -999
outliersZ(example, zCutOff = 1.0, outlierIndices = TRUE)
#> Showing indices of outliers.
#> [1] 8
outliersZ(example, zCutOff = 1.0, showZValues = TRUE)
#> Showing absolute z-scores for each value.
#> 1 outliers detected.
#> [1] -0.39 -0.39 -0.39 -0.38 -0.37 -0.37 -0.37 2.65