I would like to understand how I can drop variables from a data frame in R if they are unary, that contains only one value. I sometimes have data frames with thousands of variables, and one of my first steps would be to get rid of those variables (which often is handed over to me from a data warehouse).
I understand that I can drop columns like
drops <- c("x","z")
DF[,!(names(DF) %in% drops)]
as outlined here: Drop data frame columns by name
But I would like some way of searching through all the variables, and dropping unary only.