remove.zero.var.factors: Identify, alert, and remove columns with near zero variance.

Description Usage Arguments Examples

Description

This function is yet another fairly thin wrapper around nearZeroVar. caret's function returns a vector of indices that are near zero variance, and this function goes further to (a) inform the analyst of what columns are being removed and (b) removing those columns.

Usage

1

Arguments

data

any dataframe-esque object containing a mix of factor and numerical columns.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- data.frame(
  id     = seq(1, 10),
  age    = rpois(n=10, lambda=20),
  gender = rep(c('M', 'F'), 5),
  blood.type = factor(rep(c('A', 'B'), 5)),
  debt = factor(1e6)
)

# Removes only `debt` because (1) it's a factor and (2) has zero variance.
remove.zero.var.factors(x)

dataframing/archive documentation built on May 20, 2019, 10:19 p.m.