title: R function using a 'for' loop that returns a list with number of uppercase, lowercase and numeric values in a string
body: <p>I am trying to learn how to write a function 'f' that takes an input string 's' and returns a named list with 3 components (the number of [0, 9] digits, of small and capital letters in <code>s</code>).</p>
  <p>My answer must include a 'for' loop and to check my answer, The output of <code>str(f3(&quot;123abA&quot;))</code> is:</p>
  <pre><code>#    List of 3
  #     $ num: num 3
  #     $ l  : num 2
  #     $ L  : num 1
  </code></pre>
  <p>I did find a way to do it, but without including a 'for' loop. I know it may seem trivial to some people, but I'm just starting out and still need to develop skills using loops in R :)</p>
  <pre><code>f3 &lt;- function(s){
    number &lt;- str_count(s, &quot;[0-9]&quot;)
    lower &lt;- str_count(s, &quot;[a-z]&quot;)
    upper &lt;- str_count(s, &quot;[A-Z]&quot;)
    return(list(num = as.numeric(number), l = as.numeric(lower), L = as.numeric(upper)))
  }
  </code></pre>
  <p>Do you have an idea to help me? Thanks</p>