title: Formatting all Variables in data frame using R
body: <p>I'm using following code to format the data</p>
  
  <pre><code>lbls &lt;- sort(levels(mydata1$CIGEVER))
  lbls &lt;- (sub("^\\([0-9]+\\) +(.+$)", "\\1", lbls))
  mydata1$CIGEVER&lt;- as.numeric(sub("^\\(0*([0-9]+)\\).+$", "\\1", mydata1$CIGEVER))
  </code></pre>
  
  <p>I've 90 variables as of now. I've tried for loop to format all the variables by this code</p>
  
  <pre><code>for (i in 1:nrow(mydata1) ) 
  {
      for (j in 1:ncol(mydata1))
      {
          mydata1[i,j]&lt;- as.numeric(sub("^\\(0*([0-9]+)\\).+$", "\\1", mydata1[i,j])) 
  
      }       
  }
  </code></pre>
  
  <p>But, its taking too much time. Can anyone help me to improve the efficiency.</p>
  
  <p>Original Data looks like </p>
  
  <pre><code>Column Name
  ---------------
  
  (1) Good
  (2) Very Good
  (3) Excellent
  (4) Bad
  </code></pre>
  
  <p>And after applying the formatting</p>
  
  <pre><code>Column Name
  -------------------
  1
  2
  3
  4
  </code></pre>
  
  <p>Thanks,
  Naveen</p>