title: Save results exlusively in another data.table
body: <p>I am trying to apply the same function with different parameters to a single column and save the results in a separate data.table, without updating/modifying the original one:</p>
  
  <pre><code>library(data.table)
  set.seed(43)
  dt &lt;- data.table(
           a = sample(c("aaa","bbb","ccc"),15,replace = T),
           year=sample(c("2015","2018"),15,replace=T),
           b = sample(c("o","r","s","c","d","f"),15,replace = T),
           variant=sample(c("osdcf", "osc", "offsco", "osc", "odfsc", "oc"),15,replace = T)
         )
  stringsim_methods=c("lv","osa","dl","lcs","jw","qgram")
  for (x in stringsim_methods) { 
           dt1=dt[,(x):=stringsim("oscdf",variant, method=x),by=.(variant,year)]
           }
  </code></pre>
  
  <p>However, because of how assignment works, the original data.table will be updated as well, and dt1 will include all the other columns and rows from dt.
  The only way i was able to come up with around this was to initialize dt1 with one method and then use the for loop to calcualte the others:</p>
  
  <pre><code>dt1=dt[,.(lv=stringsim("oscdf",variant, method="lv")),by=.(variant,year)]
  for (x in stringsim_methods) {
    dt1=dt1[,(x):=stringsim("oscdf",variant, method=x)]
  }
  </code></pre>
  
  <p>Is there a more elegant way to achieve this:</p>
  
  <pre><code>   variant year        lv       osa        dl       lcs        jw    qgram
  1:   osdcf 2018 0.6000000 0.8000000 0.8000000 0.8000000 0.9333333 1.0000000
  2:  offsco 2015 0.3333333 0.3333333 0.3333333 0.5454545 0.6972222 0.7272727
  3:   osdcf 2015 0.6000000 0.8000000 0.8000000 0.8000000 0.9333333 1.0000000
  4:   odfsc 2015 0.2000000 0.2000000 0.2000000 0.6000000 0.4666667 1.0000000
  5:  offsco 2018 0.3333333 0.3333333 0.3333333 0.5454545 0.6972222 0.7272727
  6:   odfsc 2018 0.2000000 0.2000000 0.2000000 0.6000000 0.4666667 1.0000000
  7:      oc 2015 0.4000000 0.4000000 0.4000000 0.5714286 0.8000000 0.5714286
  8:     osc 2018 0.6000000 0.6000000 0.6000000 0.7500000 0.8666667 0.7500000
  9:     osc 2015 0.6000000 0.6000000 0.6000000 0.7500000 0.8666667 0.7500000
  </code></pre>
  
  <p>Thank you.</p>