title: Saving plots in a data.table list column
body: <p>When I run...</p>
  
  <pre><code>library(data.table)
  DT = CJ(id = 1, id2 = 1:3)[, .(
      d = as.IDate("2017-01-01")+1:10, v = id*10 + id2*1:10
  ), by=.(id, id2)]
  
  plotDT = DT[, {
      par(mfrow = c(uniqueN(id2), 1), mar = c(2,2,.5,2))
      .SD[,{ 
          plot(d, v, type="l")
      }, by=id2]
      .(p = .(recordPlot()))
  }, by=id]
  
  x11()
  plotDT[id == 1L, replayPlot(p[[1]])]
  </code></pre>
  
  <p>The plot from <code>DT[...]</code> is correct:</p>
  
  <p><img src="https://i.stack.imgur.com/SGyYB.png" width="300"></p>
  
  <p>While the replay is wrong:</p>
  
  <p><img src="https://i.stack.imgur.com/2hzqi.png" width="300"></p>
  
  <p>In the recordedplot, the final values of <code>x</code> and <code>y</code> are magically applied to all three graphs, probably because of how data.table handles pointers to columns defined in <code>by=</code> groups.</p>
  
  <p>I'm not really sure I understand what's going on, though, because I can change the example superficially, writing <code>v = id2*1:10</code> instead of <code>v = id*10 + id2*1:10</code> and -- poof -- the problem disappears.</p>
  
  <p>I'd like to know (i) why is this happening and (ii) what simple tweak can I make to get around it?</p>