I have a dataframe that I would like to delete rows from, based on a value in a specific column. As an example, the dataframe appears something like this:
a b c d
1 1 2 3 0
2 4 NA 1 NA
3 6 4 0 1
4 NA 5 0 0
I would like to remove all rows with a value greater than 0 in column d. I have been trying to use the following code to do this:
df <- df[!df$d > 0, ]
but this is appearing to have the effect of deleting all the value is rows with an NA value in column d. I was assuming that a na.rm = TRUE
argument was needed but I wasn't sure where to fit it in the function above.
Cheers, Ant