generateOutliers: Adds Outliers

View source: R/generateOutliers.R

generateOutliersR Documentation

Adds Outliers

Description

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

Usage

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

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 May 31, 2023, 5:55 p.m.