Learn R Programming

dataPreparation (version 0.1)

fastFilterVariables: Filtering useless variables

Description

Delete columns that are constant or in double in your dataSet set.

Usage

fastFilterVariables(dataSet, verbose = TRUE, ...)

Arguments

dataSet

Matrix, data.frame or data.table

verbose

Should the algorithm talk (logical, default to TRUE)

...

optional parameters to be passed to the function when called from another function

Value

The same dataSet set but with fewer columns. Columns that are constant, in double, or bijection of anotger have been deleted.

Examples

Run this code
# NOT RUN {
# First let's build a data.frame with 3 columns: a constant column, and a column in double
df <- data.frame(col1 = 1, col2 = rnorm(1e6), col3 = sample(c(1, 2), 1e6, replace = TRUE))
df$col4 <- df$col2
df$col5[df$col3 == 1] = "a"
df$col5[df$col3 == 2] = "b" # Same info than in col1 but with a for 1 and b for 2
head(df)

# Let's filter columns:
df <- fastFilterVariables(df)
head(df)
# }

Run the code above in your browser using DataLab