title: Add leading zero to badly formatted ZIP code
body: <p>EDIT: I just looked at some more ZIP codes in my file, and learned it is a <em>leading</em> zero these codes are missing.</p>
  
  <p>I have a bunch of zip codes formatted like:</p>
  
  <pre><code>zip
  8974
  8974
  4350
  4350
  7623
  55111
  98769
  </code></pre>
  
  <p>As you can see, these are missing the last <code>0</code> to meet the 5-digit ZIP code requirement, because of a formatting issue.</p>
  
  <p>I'm trying to do this:</p>
  
  <pre><code>attach(dat)
  
  for(x in zip){
      if(nchar(x) &lt; 5){
          x &lt;- x*10
      }
  }
  </code></pre>
  
  <p>I've also tried this:</p>
  
  <pre><code>for(x in zip){
      if(nchar(x) &lt; 5){
          zip[x] &lt;- x*10
      }
  }
  </code></pre>
  
  <p>But neither produce the desired result. How can I add the zero to these ZIP codes in R?</p>