powered by
Identifies columns in a data.frame or data.table that are binary (i.e., contain only two unique values), optionally including logical columns.
find_binary_cols(x, include_logical = FALSE)
A character vector of column names that are binary, or NULL if none are found.
A data.frame or data.table to search for binary columns.
Logical. If TRUE, logical columns are also considered binary. Default is FALSE.
df <- data.frame(a = c(0, 1, 1), b = c(TRUE, FALSE, TRUE), c = c(1, 2, 3)) find_binary_cols(df) find_binary_cols(df, include_logical = TRUE)
Run the code above in your browser using DataLab