title: dplyr filter with multiple conditions and OR
body: <p>I have a large tibble that I need to reduce by filtering. Specifically I need to filter different combinations of multiple conditions (but all from the same columns).</p>
  
  <p>My filter condition are something like</p>
  
  <pre><code>  filter(str_detect(id, "^M.+(KIT|FLEECE)"), between(f1, 300, 400),  between(f2, 1300, 1400))
   filter(str_detect(id, "^M.+(GOOSE)"), between(f1, 200, 350),  between(f2, 1200, 1400))
  </code></pre>
  
  <p>What of course works is something like</p>
  
  <pre><code>filtered1&lt;- df %&gt;%
    filter(str_detect(id, "^M.+(KIT|FLEECE)"), between(f1, 300, 400),  between(f2, 1300, 1400))
  filtered2&lt;- df %&gt;%
    filter(str_detect(id, "^M.+(GOOSE)"), between(f1, 200, 350),  between(f2, 1200, 1400))
  filtered&lt;-bind_rows(filtered1, filtered2)     
  </code></pre>
  
  <p>I'm wondering how I would combine these with some sort of OR statement like</p>
  
  <pre><code>  filtered&lt;- df %&gt;%
      filter(str_detect(id, "^M.+(KIT|FLEECE)"), between(f1, 300, 400),  between(f2, 1300, 1400)) OR
      filter(str_detect(id, "^M.+(GOOSE)"), between(f1, 200, 350),  between(f2, 1200, 1400))
  </code></pre>
  
  <p>Here is an MWE of some sample data</p>
  
  <pre><code>id&lt;-rep(c("M1_1_KIT_1", "M3_2_FLEECE_2", "M2_4_GOOSE_3", "M6_4_KIT_5"), 3)
  f1&lt;-sample(200:500, 12)
  f2&lt;-sample(1200:1500, 12)
  df&lt;-data.frame(id, f1, f2)
  df
  
            id  f1   f2
  1     M1_KIT 268 1238
  2  M3_FLEECE 270 1459
  3   M2_GOOSE 409 1471
  4     M4_KIT 344 1337
  5     M1_KIT 400 1419
  6  M3_FLEECE 210 1379
  7   M2_GOOSE 321 1356
  8     M4_KIT 478 1284
  9     M1_KIT 391 1439
  10 M3_FLEECE 382 1317
  11  M2_GOOSE 468 1273
  12    M4_KIT 306 1270
  </code></pre>
  
  <p>I would be even more happy for a more general solution, like where I put the filter values into a separate tibble and iterate over the rows, but that is beyond my R knowledge.</p>