0

Let's say this is my data frame:

df                                              
     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.00 0 0 0 Dxc8 0
2 Dxb8 Dxc8 0 Dxe8 Dxi8 0 tneg tpos 0 0 0 0  0 0.03 0 0 0 Dxi8 0

And I want rows where m is not zero. The resulting data frame should only have row 2.

Here's what I've tried:

nzg = df[, !apply(df$m == 0, 2,all)]  # dim(x) must have a positive length
nzg = df[,-df$m==0]  # undefined columns specified

As well as many variants. I'm sure it's really easy, I'm just rusty, and all the other examples are for more complex situations.

Travis Heeter
  • 13,002
  • 13
  • 87
  • 129

0 Answers0