r - Filter rows that contain a string from a vector
<p>I'm looking for a function that takes a dataframe column, checks if it contains text from a vector of strings, and filters it upon match (including a partial text match).</p>

<p>For example, take the following data frame:</p>

<pre><code>animal     |count
aardvark   |8
cat        |2
catfish    |6
dog        |12
dolphin    |3
penguin    |38
prairie dog|59
zebra      |17
</code></pre>

<p>and the following vector</p>

<pre><code>c("cat", "dog")
</code></pre>

<p>I'd like to run through the 'animal' column, checking if the value fully or partially matches by one of the strings in the vector, and filter out the ones that aren't.  The resulting data frame would be:</p>

<pre><code>animal     |count
cat        |2
catfish    |6
dog        |12
prairie dog|59
</code></pre>

<p>Thank you!</p>

<p>Sean</p>