Мы могли бы использовать colSums
:
df[, colSums(df == 100, na.rm = TRUE) > 0]
# b d
#1 10 100
#2 12 98
#3 100 100
#4 1 1
Или с dplyr
:
library(dplyr)
df %>% select_if(~any(. == 100, na.rm = TRUE))
data
df <- data.frame(a = c(89, 23, 25, 21),b = c(10, 12, 100, 1),
c = c(10, 1, 3, 6), d = c(100, 98, 100, 1))