title: Multiple filter using grep and subset in R
body: <p>I'm trying to create a filter to remove lines from a dataset using grep and subset together.</p>
  
  <p>Sample dataset:</p>
  
  <pre><code>id &lt;- 1:10
  problem &lt;- c("a" , "b", "c", "d", "a","b","c","a", "b", "a")
  solution1 &lt;- c("eat", "sleep", "drink", "play", "sleep", "play", "play", "drink", "play", "eat")
  solution2 &lt;- c("read", "read", "eat", "drink", "eat", "sleep", "eat", "read", "eat", "play")
  df &lt;- c(id, problem, solution1, solution2)
  </code></pre>
  
  <p>I'm trying to remove those rows with problem "a" and have "eat" in either solution1 or solution2.</p>
  
  <p>The result is that it should remove id 1, 5 and 10.</p>
  
  <p>I have tried using:</p>
  
  <pre><code>df &lt;- subset(df, problem=="a" &amp; !(grepl("eat", df)))
  </code></pre>
  
  <p>and</p>
  
  <pre><code>df &lt;- df[!grepl("eat", df) &amp; grepl("a", df$problem)]
  </code></pre>
  
  <p>Can't seem to find a similar solution on StackOverflow or on other websites I Googled.</p>
  
  <p>Would appreciate if anyone can help.  Thanks!</p>