I think this is a bug. DT.2 <- DT.1 doesn't seem to make a copy in all cases.<div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">> DT.1 <- data.table(x=1, y=1)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">> DT.2 <- DT.1</font></div><div><font class="Apple-style-span" face="'courier new', monospace">> </font></div><div><font class="Apple-style-span" face="'courier new', monospace">> # Both DT.1 and DT.2 are changed.</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">> DT.2[, y := NULL]</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> x</font></div><div><font class="Apple-style-span" face="'courier new', monospace">[1,] 1</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">> DT.1</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> x</font></div><div><font class="Apple-style-span" face="'courier new', monospace">[1,] 1</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">> DT.2</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> x</font></div><div><font class="Apple-style-span" face="'courier new', monospace">[1,] 1</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">> </font></div><div><font class="Apple-style-span" face="'courier new', monospace">> # Only DT.2 is changed</font></div><div><font class="Apple-style-span" face="'courier new', monospace">> DT.2[, y := x]</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> x y</font></div><div><font class="Apple-style-span" face="'courier new', monospace">[1,] 1 1</font></div><div><font class="Apple-style-span" face="'courier new', monospace">> DT.1</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> x</font></div><div><font class="Apple-style-span" face="'courier new', monospace">[1,] 1</font></div><div><font class="Apple-style-span" face="'courier new', monospace">> DT.2</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> x y</font></div><div><font class="Apple-style-span" face="'courier new', monospace">[1,] 1 1</font></div></div><div><br></div>