title: Format any numeric value of a data frame
body: <p>I have the following data frame:</p>
  <pre><code>col1 &lt;- c(0.00002, 0.001, 0.5689785541122558)
  col2 &lt;- c(3.5, 45.6546548788, 12585.5663)
  col3 &lt;- c(200.00, 34.52, NA)
  tab_test &lt;- data.frame(col1, col2, col3)
  </code></pre>
  <p>I would like to format all numbers appropriately by writing a single function. I'm using this code to force scientific notation when numbers are smaller than 0.001</p>
  <pre><code>formatta_val &lt;- function(x) {
    mapply(format, x, scientific = abs(x) &lt; 0.001, digit = 1, nsmall = 3)
  }
  replace(tab_test, TRUE, lapply(tab_test, formatta_val))
  </code></pre>
  <p>I would like to upgrade <code>formatta_val()</code> in order to get the data frame as follows:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>col1</th>
  <th>col2</th>
  <th>col3</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2e-05</td>
  <td>3.5</td>
  <td>200</td>
  </tr>
  <tr>
  <td>0.001</td>
  <td>45.65</td>
  <td>34.52</td>
  </tr>
  <tr>
  <td>0.569</td>
  <td>12,585.57</td>
  <td></td>
  </tr>
  </tbody>
  </table>
  </div>