I have a dataframe, df. I would like to remove all rows that contain the value 0 from the dataframe.
ID Value
A 8
A 8
A 0
B 1
B 2
C 0
Desired outcome:
ID Value
A 8
A 8
B 1
B 2
Here is the dput:
structure(list(ID = structure(c(1L, 1L, 1L, 2L, 2L, 3L), .Label = c("A",
"B", "C"), class = "factor"), Value = c(8L, 8L, 0L, 1L, 2L, 0L
)), class = "data.frame", row.names = c(NA, -6L))
This is what I tried:
I was using the same concept to remove a column:
library(dplyr)
df%>% select(-c()
However, I am unsure how to specify how to remove the row if and only if it contains a 0.