title: Using regex to add `.0` to the end of numbers without a decimal
body: <p>I'm trying to use regex to add &quot;.0&quot; to the end of numbers that do not already have a decimal.</p>
  <p>For a simple reproducible example:</p>
  <pre class="lang-r prettyprint-override"><code>library(tidyverse)
  library(stargazer)
  
  mtcars %&gt;% 
    head(3) %&gt;% 
    select(mpg, hp) %&gt;% 
    stargazer(summary = FALSE, digits = 1, type = &quot;text&quot;)
  </code></pre>
  <p>Gives output that looks like this:</p>
  <pre><code>#&gt; 
  #&gt; ======================
  #&gt;               mpg  hp 
  #&gt; ----------------------
  #&gt; Mazda RX4      21  110
  #&gt; Mazda RX4 Wag  21  110
  #&gt; Datsun 710   22.8   93 
  #&gt; ----------------------
  </code></pre>
  <p>I would like to add <code>&quot;.0&quot;</code> to all of the numbers that do not have a decimal place already. So my desired output would be the <code>html</code> version of this:</p>
  <pre><code>#&gt; ======================
  #&gt;               mpg  hp 
  #&gt; ----------------------
  #&gt; Mazda RX4     21.0  110.0
  #&gt; Mazda RX4 Wag 21.0  110.0
  #&gt; Datsun 710    22.8   93.0 
  #&gt; ----------------------
  </code></pre>
  <p>The table above was in text format for readability, but my real problem is in HTML, so I'm looking at a problem like:</p>
  <pre class="lang-r prettyprint-override"><code>library(tidyverse)
  library(stargazer)
  
  mtcars %&gt;% 
    head(3) %&gt;% 
    select(mpg, hp) %&gt;% 
    stargazer(summary = FALSE, digits = 1, type = &quot;html&quot;)
  
  
  #&gt; &lt;table style=&quot;text-align:center&quot;&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot; style=&quot;border-bottom: 1px solid black&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;text-align:left&quot;&gt;&lt;/td&gt;&lt;td&gt;mpg&lt;/td&gt;&lt;td&gt;hp&lt;/td&gt;&lt;/tr&gt;
  #&gt; &lt;tr&gt;&lt;td colspan=&quot;3&quot; style=&quot;border-bottom: 1px solid black&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;text-align:left&quot;&gt;Mazda RX4&lt;/td&gt;&lt;td&gt;21&lt;/td&gt;&lt;td&gt;110&lt;/td&gt;&lt;/tr&gt;
  #&gt; &lt;tr&gt;&lt;td style=&quot;text-align:left&quot;&gt;Mazda RX4 Wag&lt;/td&gt;&lt;td&gt;21&lt;/td&gt;&lt;td&gt;110&lt;/td&gt;&lt;/tr&gt;
  #&gt; &lt;tr&gt;&lt;td style=&quot;text-align:left&quot;&gt;Datsun 710&lt;/td&gt;&lt;td&gt;22.8&lt;/td&gt;&lt;td&gt;93&lt;/td&gt;&lt;/tr&gt;
  #&gt; &lt;tr&gt;&lt;td colspan=&quot;3&quot; style=&quot;border-bottom: 1px solid black&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
  </code></pre>
  <p>Can anyone help with a <code>gsub</code>, regex, or <code>stringr</code> solution to this?</p>
  <p>This <a href="https://stackoverflow.com/questions/39937400/decimal-numbers-in-r-stargazer">previous question</a> has answers for the latex solution, but I'm after a HTML solution.</p>