trim_outliers: Trim Outliers

Description Usage Arguments Examples

View source: R/trim_outliers.R

Description

Remove outliers by either choosing a vector of column names to include for consideration or choosing a vector for exclusion. Either include or exclude must be non-NULL (not neither and not both).

Usage

1
2
trim_outliers(df, cutoff = 1.96, exclude = NULL, include = NULL,
  keep_scaled = TRUE)

Arguments

df

A dataframe.

cutoff

A numeric standard deviation cutoff value.

exclude

Vector of variables not to subject to cutting off.

include

Vector of variables to subject to cutting off.

keep_scaled

Should the newly scaled numeric variables be kept in the output?

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
trim_outliers(iris, cutoff = 1,
              exclude = c("Species", "Sepal.Length"), keep_scaled = FALSE)
trim_outliers(iris, cutoff = 2,
              include = c("Petal.Width", "Sepal.Length"), keep_scaled = TRUE)

# Error -- exclude and include can't both be non-NULL
testthat::expect_error(
  trim_outliers(iris, cutoff = 2, exclude = "Species",
              include = c("Petal.Width", "Sepal.Length"), keep_scaled = TRUE))

# Error -- exclude and include can't both be NULL
testthat::expect_error(
  trim_outliers(iris, cutoff = 2, keep_scaled = TRUE))

aedobbyn/dobtools documentation built on May 28, 2019, 2:33 a.m.