title: grepl in R to find matches to any of a list of character strings
body: <p>Is it possible to use a <em>grepl</em> argument when referring to a list of values, maybe using the %in% operator? I want to take the data below and if the animal name has "dog" or "cat" in it, I want to return a certain value, say, "keep"; if it doesn't have "dog" or "cat", I want to return "discard". </p>
  
  <pre><code>data &lt;- data.frame(animal = sample(c("cat","dog","bird", 'doggy','kittycat'), 50, replace = T))
  </code></pre>
  
  <p>Now, if I were just to do this by strictly matching values, say, "cat" and "dog', I could use the following approach:</p>
  
  <pre><code>matches &lt;- c("cat","dog")
  
  data$keep &lt;- ifelse(data$animal %in% matches, "Keep", "Discard")
  </code></pre>
  
  <p>But using grep or grepl only refers to the first argument in the list:</p>
  
  <pre><code>data$keep &lt;- ifelse(grepl(matches, data$animal), "Keep","Discard")
  </code></pre>
  
  <p>returns </p>
  
  <pre><code>Warning message:
  In grepl(matches, data$animal) :
    argument 'pattern' has length &gt; 1 and only the first element will be used
  </code></pre>
  
  <p>Note, I saw this thread in my search, but this doesn't appear to work:
  <a href="https://stackoverflow.com/questions/7597559/grep-in-r-with-a-list-of-patterns">grep using a character vector with multiple patterns</a></p>