r here.
<code>nchar()</code> requires a character vector, so it will return an
error if used on a factor. <code>str_length()</code> can handle a factor
input.</p>
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" tabindex="-1"></a><span class="co"># base</span></span>
<span id="cb17-2"><a href="#cb17-2" tabindex="-1"></a><span class="fu">nchar</span>(<span class="fu">factor</span>(<span class="st">&quot;abc&quot;</span>)) </span>
<span