I have a data.frame:
SelectVar
a b c d e f g h i j k l ll m n o p q r
1 Dxa8 Dxa8 0 Dxa8 Dxa8 0 Dxa8 Dxa8 0 0 0 0 0 0 0 0 0 Dxc8 0
2 Dxb8 Dxc8 0 Dxe8 Dxi8 0 tneg tpos 0 0 0 0 0 0 0 0 0 Dxi8 0
I would like to remove the columns with zero values in both rows from the data frame, so it yields a data frame as below:
SelectVar
a b d e g h q
1 Dxa8 Dxa8 Dxa8 Dxa8 Dxa8 Dxa8 Dxc8
2 Dxb8 Dxc8 Dxe8 Dxi8 tneg tpos Dxi8
Have tried:
SelectVar!=0
which yields a True/False dataframe, and:
SelectVar[, colSums(abs(SelectVar)) ! == 0]
which yields an error.
How could I remove the columns with zero values in each row?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…