title: How to split a number into digits in R
body: <p>I have a data frame with a numerical ID variable which identify the Primary, Secondary and Ultimate Sampling Units from a multistage sampling scheme. I want to split the original ID variable into three new variables, identifying the different sampling units separately:</p>
  
  <p>Example:</p>
  
  <pre><code>&gt;df[1:2,]
  ID Var        var1     var2      var3     var4         var5  
  501901          9    SP.1          1        W         12.10    
  501901          9    SP.1          2        W         17.68  
  </code></pre>
  
  <p>What I want:</p>
  
  <pre><code>&gt;df[1:2,]
  ID1    ID2     ID3   var1   var2  var3     var4    var5  
  5      01      901    9    SP.1    1        W     12.10    
  5      01      901    9    SP.1    2        W     17.68  
  </code></pre>
  
  <p>I know there is some functions available in R to split character strings, but I could not find same facilities for numbers. </p>
  
  <p>Thank you,</p>
  
  <p>Juan</p>