What is the best way to filter rows from data frame when the values to be deleted are stored in a vector? In my case I have a column with dates and want to remove several dates.
I know how to delete rows corresponding to one day, using !=
, e.g.:
m[m$date != "01/31/11", ]
To remove several dates, specified in a vector, I tried:
m[m$date != c("01/31/11", "01/30/11"), ]
However, this generates a warning message:
Warning message:
In `!=.default`(m$date, c("01/31/11", "01/30/11")) :
longer object length is not a multiple of shorter object length
Calls: [ ... [.data.frame -> Ops.dates -> NextMethod -> Ops.times -> NextMethod
What is the correct way to apply a filter based on multiple values?