title: Strange behavior while counting NAs, NANs and Inf's
body: <p>I wrote a small function that would count the number of NA, NaN an Inf in a tibble data frame as follows:</p>
  
  <pre><code>check.for.missing.values &lt;- function(df) {
       return(  sum(is.na(as.matrix(df)) &amp; !is.nan(as.matrix(df))) +    #NAs
                sum(is.infinite(as.matrix(df))) +                       #Infs
                sum(is.nan(as.matrix(df)))                              #NaNs
  )}
  </code></pre>
  
  <p>I tested it with the following tibble:</p>
  
  <pre><code>x1 &lt;- tibble(x = 1:7, 
               y = c(NA,NA,Inf,Inf,Inf,-Inf,-Inf), 
               z = c(-Inf,-Inf,NaN,NaN,NaN,NaN,NaN))
  x1
  # A tibble: 7 × 3
    x     y     z
  &lt;int&gt; &lt;dbl&gt; &lt;dbl&gt;
    1     1    NA  -Inf
    2     2    NA  -Inf
    3     3   Inf   NaN
    4     4   Inf   NaN
    5     5   Inf   NaN
    6     6  -Inf   NaN
    7     7  -Inf   NaN`
  </code></pre>
  
  <p>And I get</p>
  
  <pre><code>check.for.missing.values(x1)
  [1] 14
  </code></pre>
  
  <p>which of course is the correct answer.</p>
  
  <p>Now, if the tibble that I pass on to the function happens to include observations in date format, then the functions stops working and I can't figure out why:</p>
  
  <pre><code>x2 &lt;- mutate(x1, date = as.Date('01/07/2008','%d/%m/%Y'))
  x2
  
  # A tibble: 7 × 4
    x     y     z       date
  &lt;int&gt; &lt;dbl&gt; &lt;dbl&gt;     &lt;date&gt;
    1     1    NA  -Inf 2008-07-01
    2     2    NA  -Inf 2008-07-01
    3     3   Inf   NaN 2008-07-01
    4     4   Inf   NaN 2008-07-01
    5     5   Inf   NaN 2008-07-01
    6     6  -Inf   NaN 2008-07-01
    7     7  -Inf   NaN 2008-07-01`
  
  check.for.missing.values(x2)
  [1] 7
  </code></pre>
  
  <p>Any clues as to what's going on? </p>
  
  <p>Thanks</p>
  
  <p>reyemarr</p>