title: Removing commas from strings and numbers
body: <p>Using R, how do I remove commas if its a number and replace commas with a space if its a letter?: </p>
  
  <pre><code>  Company        | Sales   |
    -------------------------
    go, go, llc    |2,550.40 |
    tires &amp; more   |  500    |
    l-m tech       |1,000.67 |
  </code></pre>
  
  <p>Sample data:</p>
  
  <pre><code>data = matrix(c('go, go,llc', 'tires &amp; more', 'l-m technology',
   formatC(2550.40, format="f", big.mark=",", digits=2), 500, 
   formatC(1000.67, format="f", big.mark=",", digits=2)), 
   nrow=3, 
   ncol=2)
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>  Company      | Sales  |
    -----------------------
    go go llc    |2550.40 |
    tires &amp; more |  500   |
    l-m tech     |1000.67 |
  </code></pre>
  
  <p>What I've tried:</p>
  
  <pre><code>data &lt;- sapply(data, function(x){
             if (grepl("[[:punct:]]",x)){
                if (grepl("[[:digit:]]",x)){
                   x &lt;- gsub(",","",x)
                }
                else{
                   x &lt;- gsub(","," ",x)
                }
             }
          })
  
  print(nrow(data)) # returns NULL
  </code></pre>