Deselect columns that are all NA
deselect_if_all_same(data, na.rm = FALSE)
library(tidyverse) test_data <- tibble(A = rep(NA_character_, 5), B = LETTERS[1:5], C = 1:5, D = rep("Z", 5)) test_data#> # A tibble: 5 x 4 #> A B C D #> <chr> <chr> <int> <chr> #> 1 NA A 1 Z #> 2 NA B 2 Z #> 3 NA C 3 Z #> 4 NA D 4 Z #> 5 NA E 5 Z#> # A tibble: 5 x 3 #> B C D #> <chr> <int> <chr> #> 1 A 1 Z #> 2 B 2 Z #> 3 C 3 Z #> 4 D 4 Z #> 5 E 5 Zdeselect_if_all_same(test_data)#> # A tibble: 5 x 2 #> B C #> <chr> <int> #> 1 A 1 #> 2 B 2 #> 3 C 3 #> 4 D 4 #> 5 E 5