title: R Remove leading 0's from a factor string
body: <p>I have imported multiple excel files into R using the read.csv() function. </p>
  
  <p>On the smaller files, the leading 0's in the uniqueID column have been kept
      e.g. 085405, 021X1B, 0051012</p>
  
  <p>However on the larger files, the leading 0's have been dropped from the uniqueID's where they only contain numbers
      e.g. 85405, 021X1B, 51012</p>
  
  <p>I would like to drop the leading 0's from all uniqueID's so I am able to merge.</p>
  
  <p>I have tried using the following code:</p>
  
  <pre><code>Test$UniqueID2 &lt;- substr(Dataset$UniqueID,regexpr("[^0]",Dataset$UniqueID,nchar(Dataset$UniqueID))
  </code></pre>
  
  <p>This generated the following error:</p>
  
  <pre><code>Error in nchar(Dataset$UniqueID) : 
    'nchar()' requires a character vector
  </code></pre>
  
  <p>A solution which will allow me to drop leading 0's in R would be much appreciated.</p>