detect_const_cols {dataframeexplorer} | R Documentation |
Detect if any column of a data.frame has constant values.
Description
It occasionally happens that a column in dataframe contains a single value throughout. This could lead to redundant computational cost and unexpected behavior in Machine Learning methods. This function scans though all columns of dataframe to examine if any column has no variation.
Usage
detect_const_cols(dataset, return_type = "col_names", ignore_na = F)
Arguments
dataset |
A data.frame |
return_type |
How to return detected constant columns Use "col_names", "col_positions" or "dataset" to return dataset with deleted constant columns |
ignore_na |
Whether NA should be ignored while checking if a column has just 1 unique value |
Value
. A vector of constant column-names or column positions or dataset with deleted constant columns. Use return_type parameter to specify.
Examples
## Not run:
detect_const_cols(dataset = head(mutate(mtcars, mpg_2 = 999)))
## End(Not run)
[Package dataframeexplorer version 1.0.2 Index]