title: R program, pad characters with 0, max width=3
body: <p>I am trying to pad each element of a vector with "0", such that the maximum width is 3</p>
  
  <p>Example:</p>
  
  <ul>
  <li>0 becomes 000</li>
  <li>12 becomes 012</li>
  <li>100 stays 100</li>
  </ul>
  
  <p>Here is the code</p>
  
  <pre><code>myvector &lt;- c("2", "3", "33", "90", "120")
  newvector &lt;- lapply(myvector,formatC(width=3, format="s", flag="0"))
  </code></pre>
  
  <p>And when I use lapply, I get error</p>
  
  <pre><code>Error in formatC(width = 3, format = "s", flag = "0") : 
    argument "x" is missing, with no default
  </code></pre>
  
  <p>Which makes no sense because I am using it in <code>lapply</code>, and the first argument of <code>lapply</code> is <code>myvector</code>.</p>