-1"></a><span class="co">#&gt; [1] 1 2 3 4</span></span></code></pre></div>
<p>In base you would use <code>grep()</code> while in stringr you use
<code>str_which()</code> (by analogy to <code>which()</code>).</p>
</div>
<div id="str_count-count-the-number-of-matches-in-a-string" class="section level2">
<h2><code>str_count()</code>: Count the number of matches in a
string</h2>
<p>How many “a”s are in each fruit?</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><sp