Data Science Desktop Survival Guide
by Graham Williams |
|||||
Constant Variables |
20200814 We may wish and typically do ignore variables (dataset columns) with constant values as they add no extra information to the analysis.
# Identify variables that have a single value.
ds %>% select(all_of(vars)) %>% sapply(function(x) all(x == x[1L])) %>% which() %>% names() %T>% print() -> constants
If you are accumulating a list of variables to ignore the add these constants to that list.
|
# Add them to the variables to be ignored for modelling.
ignore <- union(ignore, constants) %T>% print()
|