title: Check if the number is integer
body: <p>I was surprised to learn that R doesn't come with a handy function to check if the number is integer.</p>
  
  <pre><code>is.integer(66) # FALSE
  </code></pre>
  
  <p>The <a href="http://web.mit.edu/~r/current/lib/R/library/base/html/integer.html" rel="noreferrer">help files warns</a>:</p>
  
  <blockquote>
    <p><code>is.integer(x)</code> does not test if <code>x</code>
    contains integer numbers! For that,
    use <code>round</code>, as in the function
    <code>is.wholenumber(x)</code> in the examples.</p>
  </blockquote>
  
  <p>The example has this custom function as a "workaround"</p>
  
  <pre><code>is.wholenumber &lt;- function(x, tol = .Machine$double.eps^0.5)  abs(x - round(x)) &lt; tol
  is.wholenumber(1) # is TRUE
  </code></pre>
  
  <p>If I would have to write a function to check for integers, assuming I hadn't read the above comments, I would write a function that would go something along the lines of</p>
  
  <pre><code>check.integer &lt;- function(x) {
      x == round(x)
  }
  </code></pre>
  
  <p>Where would my approach fail? What would be your work around if you were in my hypothetical shoes?</p>