| remove_empty_cols | R Documentation |
Remove empty columns (i.e., columns that only contain NA) from a tibble or data frame.
remove_empty_cols(data, always_keep = NULL, show_removed_cols = TRUE)
data |
A tibble or data frame in wide format. |
always_keep |
Specify columns that should always be kept, regardless if they only contain |
show_removed_cols |
If |
A tibble or data frame in wide format without empty columns.
# Columns `a` and `d` contains only `NA` and should be removed
na_tibble <- tibble::tibble(
a = c(NA, NA, NA),
b = c(1, 2, 3),
c = c(NA, 2, 3),
d = c(NA, NA, 3),
e = c(NA, NA, NA)
)
remove_empty_cols(na_tibble)
# Columns `a` and `d` contains only `NA` but `a` should be kept anyways
remove_empty_cols(na_tibble, always_keep = a)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.