I want to identify (and subsequently delete) character vectors from a dataset, that consist of entries, that are all equal (e.g. do not have any variation):
test_data <- tibble(a = c("A", "B", "C"), b = c("A", "A", "A"), c = c("", "", ""), d = 1:3)
test_data
# A tibble: 3 x 4
a b c d
<chr> <chr> <chr> <dbl>
1 A A "" 1
2 B A "" 2
3 C A "" 3
I want the result to be something like this:
# A tibble: 3 x 2
a d
<chr> <dbl>
1 A 1
2 B 2
3 C 3
Of course I can achieve that by doing:
out <- c("b", "c")
test_data %>% select(- one_of((out)))
But as I have a lot of those columns and also a lot of rows, I'd prefer not to have to do it "manualy".
I found this but it only works for numeric vectors.