I need to remove several rows that meet a condition within a subset.
For instance, using the iris dataset, I would like to remove all the rows in which Sepal.Width = 3.2, but only within setosa
I have tried this: filter(iris, !Species %in% "setosa" & !Sepal.Width==3.2) But his removes all rows containing setosaand all rows in which Sepal.Width==3.2, rather than considering both conditions at the same time (i.e. only remove the rows of the condition within ‘setosa’ and leave the rest
filterand analogues ([]andsubset, for example) will all work and no subsetting of subsets is ever needed. In this case you could use!(x & y)as in SabDeM's answer, or the arguably less readable!x | !y!( <...conditions...> )here on SO from you (or maybe another power user), because you commented my answer and made me realize the readability of it. As always thank you.