kill_cols: Kill off non-informative columns in a data.frame

Description Usage Arguments Value Author(s) Examples

Description

kill_cols accepts a data.frame or matrix, and returns another, containg only the columns with more than one unique non-missing value. By default, empty strings ("") are converted to NA, and not considered informative.

Usage

1
2
3
kill_cols(x, empty_strings = TRUE)

killcols(x, empty_strings = TRUE)

Arguments

x

A data.frame

empty_strings

logical. Should empty strings ("") be converted to NA?

Value

A data.frame, less non-varying variables.

Author(s)

Brendan Rocks rocks.brendan@gmail.com

Examples

1
2
3
4
5
6
7
8
9
# If we filter test_data down to just those in a particular income group,
# income groups no longer vary

data(test_data)
test_data2 <- test_data[test_data$income == '$0 - $40k',]

# Now kill_cols will remove the income column, as it no longer varies

kill_cols(test_data2)

brendan-R/brocks documentation built on May 13, 2019, 5:07 a.m.