Remove constant columns from a data.frame or matrix.
remove_constant(dat, na.rm = FALSE)
the input data.frame or matrix.
should NA
values be removed when considering whether a
column is constant? The default value of FALSE
will result in a column
not being removed if it's a mix of a single value and NA
.
remove_empty()
for removing empty
columns or rows.
Other remove functions:
remove_empty()
# NOT RUN {
remove_constant(data.frame(A=1, B=1:3))
# To find the columns that are constant
data.frame(A=1, B=1:3) %>%
dplyr::select_at(setdiff(names(.), names(remove_constant(.)))) %>%
unique()
# }
Run the code above in your browser using DataLab