R/cinf-filters.R

Defines functions rm_low_var

# Filters out columns from data frame with low variance
rm_low_var <- function(df, threshold=0.0001) {
  ind <- logical()
  ncol <- length(df)
  for (col in 1:ncol) {
    if (var(df[[col]]) < threshold) {
	  ind[col] <- FALSE
	} else {
	  ind[col] <- TRUE
	}
  }
  df[ind]
}

Try the cinf package in your browser

Any scripts or data that you put into this service are public.

cinf documentation built on May 2, 2019, 5 p.m.