Learn R Programming

simulariatools (version 3.1.0)

removeOutliers: Remove data outliers

Description

Remove data outliers based on the interquartile range.

Usage

removeOutliers(x, k = 1.5)

Value

A numeric vector with the same length as input vector.

Arguments

x

vector of data.

k

factor applied to the interquartile range (default = 1.5).

Details

The interquartile range IQR is computed from input dataset as IQR = Q3 - Q1, where Q1 is 25th percentile and Q3 is the 75th percentile. Values larger than Q3 + k * IQR and smaller than Q1 - k * IQR are deemed as outliers and substituted with NA's.

The default value of k is 1.5.

Examples

Run this code
mydata <- c(-10 * runif(10), runif(10))
removeOutliers(mydata)

Run the code above in your browser using DataLab