generateOutliers: Adds Outliers to a Vector, Matrix or Data Frame

Description Usage Arguments Value See Also Examples

View source: R/generateOutliers.R

Description

Takes a vector, matrix or data frame and replaces some numeric values by outliers.

Usage

1
generateOutliers(x, p = 0.05, sd_factor = 5, seed = NULL)

Arguments

x

A vector, matrix or data.frame.

p

Proportion of outliers to add to x. In case x is a data.frame, p can also be a vector of probabilities per column or a named vector (see examples).

sd_factor

Each outlier is generated by shifting the original value by a realization of a normal random variable with sd_factor times the original sample standard deviation.

seed

An integer seed.

Value

x with outliers.

See Also

outForest.

Examples

1
2
3
4
5
6
generateOutliers(1:10, seed = 334, p = 0.3)
generateOutliers(cbind(1:10, 10:1), p = 0.2)
head(generateOutliers(iris))
head(generateOutliers(iris, p = 0.2))
head(generateOutliers(iris, p = c(0, 0, 0.5, 0.5, 0.5)))
head(generateOutliers(iris, p = c(Sepal.Length = 0.2)))

outForest documentation built on Jan. 7, 2021, 9:10 a.m.