title: R : data.table returns an empty row when the it actually exist
body: <p>I have data that contains dates.</p>
  
  <pre><code>newdata &lt;- data.table(example.dates)
  
  &gt; newdata
         start_date  paid_date
      1: 2014-08-01 2015-09-24
      2: 2015-08-01 2015-10-22
      3: 2015-10-01 2015-12-45
      4: 2015-11-01 2016-03-23
      5: 2016-12-01 2017-02-06
     ---                      
    100: 2018-02-05 2018-04-28
    101: 2018-03-02 2018-07-18
    102: 2018-06-14 2018-10-13
    103: 2018-08-16 2018-11-04
    104: 2018-10-19 2018-11-22
  </code></pre>
  
  <p>I have a function that calculates difference between dates in months</p>
  
  <pre><code>difference_month &lt;- function(new_date, old_date) {
    start_date &lt;- old_date %&gt;% as.Date() %&gt;% as.yearmon()
    end_date &lt;- new_date %&gt;% as.Date() %&gt;% as.yearmon()
    diff_mon &lt;- (end_date - start_date) * 12 
    return(diff_mon)
  }
  </code></pre>
  
  <p>and added 'diff' column in newdata table.</p>
  
  <pre><code>newdata[,diff := difference_month(paid_date,start_date)]
  
  &gt; newdata
        start_date  paid_date diff
      1: 2014-08-01 2015-09-24  13
      2: 2015-08-01 2015-10-22  2
      3: 2015-10-01 2015-12-45  2
      4: 2015-11-01 2016-03-23  4
      5: 2016-12-01 2017-02-06  2
     ---                      
    100: 2018-02-05 2018-04-28  2
    101: 2018-03-02 2018-07-18  4
    102: 2018-06-14 2018-10-13  4
    103: 2018-08-16 2018-11-04  3
    104: 2018-10-19 2018-11-22  1
  </code></pre>
  
  <p>But, this appears when I want to see the rows that has 2 months difference.</p>
  
  <pre><code>&gt; newdata[diff == 2]
  Empty data.table (0 rows) of 3 cols: start_date,paid_date,diff
  </code></pre>
  
  <p>However, it works when I select a row that contains 2 months difference and use that to find the whole rows that contain 2 months difference.</p>
  
  <pre><code>x &lt;- newdata[2][[3]]
  
  &gt; newdata[diff == x]
    start_date  paid_date diff
  1: 2015-08-01 2015-10-22  2
  2: 2015-10-01 2015-12-45  2
  3: 2016-12-01 2017-02-06  2                      
  4: 2018-02-05 2018-04-28  2
  </code></pre>
  
  <p>I checked str() and 'diff' was in numeric.</p>
  
  <p>Why does this return empty rows when 2 months difference actually exist?</p>
  
  <pre><code>newdata[diff == 2]
  </code></pre>