I am struggling to select all columns whose elements are all 0. Here is a simple example:
df <- data.frame(A=c(1,0,1,0),B=c(0,0,0,0),C=c(1,1,0,0),D=c(0,0,0,0))
df
A B C D
1 1 0 1 0
2 0 0 1 0
3 1 0 0 0
4 0 0 0 0
I want to select Columns B and D. I know the dplyr::selectallows to select by colnames. But how to select columns by their values? Something like select(across(everything(),~.x==0)). But the across() cannot be used in select().