title: Assignment by reference and aggregation creates duplicates in data table R
body: <p>I'm observing a weird behavior with data.table in R and I'm wondering whether this is a bug. Here is the code I use:</p>
  
  <pre><code>num_req &lt;- fread("number_requests.csv")
  num_req[, nrequests := sum(nrequests, na.rm=T), by = list(reqtype, server, timestamp)]
  </code></pre>
  
  <p>The part of the output I find weird is the following:</p>
  
  <pre><code>   nrequests timestamp    reqtype   server   
  3:        22 1489276860   reqtype1  server1
  4:        22 1489276860   reqtype1  server1
  </code></pre>
  
  <p>As you can see, I end up with a duplicate row even though all keys are exactly the same. </p>
  
  <p>If re-run the aggregation on the output I get</p>
  
  <pre><code>   nrequests timestamp    reqtype   server   
  3:        44 1489276860   reqtype1  server1
  4:        44 1489276860   reqtype1  server1
  </code></pre>
  
  <p>Now, if I do </p>
  
  <pre><code>tmp2 &lt;- num_req[, list(nrequests = sum(nrequests, na.rm=T)), by = list(reqtype, server, timestamp)]
  </code></pre>
  
  <p>then I do not get any duplicated rows. </p>
  
  <p>Some info:</p>
  
  <ul>
  <li><p>The dataset has 75015360 rows but even working with a subset (<code>mysubset &lt;- num_req[timestamp==1489276860]</code>) shows the same duplication if I use the assignment by reference</p></li>
  <li><p>I'm using data.table version 1.10.4 </p></li>
  <li>I'm using R version 3.3</li>
  <li>I'm working on RStudio Server version 1.0.44</li>
  <li>the host virtual machine is Red Hat Enterprise Linux Server release 6.8 (Santiago)</li>
  </ul>
  
  <p>The question is whether I'm misusing the <code>:=</code> operator or if this is a bug?</p>
  
  <p>Thanks for your help!</p>