How to create new column in a data.table when the name of column must be a string
<p>How to create new column in a data.table when the name of column must be a string or character? </p>

<p>For example:</p>

<pre><code>library(data.table)
DT = data.table(v1=c(1,2,3), v2=2:4)
new_var &lt;- "v3"
DT[, new_var:=v2+5]
</code></pre>

<p>I Get</p>

<pre><code>DT
#&gt;    v1 v2 new_var
#&gt; 1:  1  2       7
#&gt; 2:  2  3       8
#&gt; 3:  3  4       9
</code></pre>

<p>But, I want</p>

<pre><code>#&gt;    v1 v2      v3
#&gt; 1:  1  2       7
#&gt; 2:  2  3       8
#&gt; 3:  3  4       9
</code></pre>