removeOutlierObservations: Removes observations with outliers

Description Usage Arguments Value Examples

View source: R/descriptives.R

Description

Function removes outliers for a given set of variables at a relative percentage at both ends.

Usage

1
removeOutlierObservations(df, variables = colnames(df), cutoff = 0.5)

Arguments

df

Data frame, matrix or tibble with input variables

variables

Variables used for trimming. By default, all variables are included.

cutoff

Relative cutoff on each side in percent (default: 0.5, i.e. 0.5% at each end).

Value

Returns vector with indices of the observations to be removed.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
d <- data.frame(x1 = rnorm(200), x2 = rnorm(200), y = rnorm(200))

d_trimmed <- removeOutlierObservations(d)
dim(d_trimmed)

d_trimmed <- removeOutlierObservations(d, variables = "y", cutoff = 2.0)
dim(d_trimmed)

d_trimmed <- removeOutlierObservations(d, variables = c("x1", "x2"), cutoff = 2.0)
dim(d_trimmed)

sfeuerriegel/ResearchGroupTools documentation built on May 29, 2019, 8:01 p.m.