I have a problem to solve how to remove rows with a Zero value in R. In others hand, I can use na.omit()
to delete all the NA values or use complete.cases()
to delete rows that contains NA values.
Is there anyone know how to remove rows with a Zero Values in R?
For example :
Before
| DateTime | Mac1 | Mac2 | Mac3 | Mac4 |
----------------------------------------------------
| 2011-04-02 06:00 | 20 | 0 | 20 | 20 |
| 2011-04-02 06:05 | 21 | 21 | 21 | 21 |
| 2011-04-02 06:10 | 22 | 22 | 22 | 22 |
| 2011-04-02 06:15 | 23 | 23 | 0 | 23 |
| 2011-04-02 06:20 | 24 | 24 | 24 | 24 |
| 2011-04-02 06:25 | 0 | 25 | 25 | 0 |
After
| DateTime | Mac1 | Mac2 | Mac3 | Mac4 |
----------------------------------------------------
| 2011-04-02 06:05 | 21 | 21 | 21 | 21 |
| 2011-04-02 06:10 | 22 | 22 | 22 | 22 |
| 2011-04-02 06:20 | 24 | 24 | 24 | 24 |
data[which(data==0)] = NA
– Aguilardata[which(data==0)] = NA_character_
– Strata