title: functions with data.table variables which names are stored in a character vector
body: <p>I am not a big data.table expert but I am somehow puzzled by some things. Here is my simple example:</p>
  
  <pre><code>test&lt;-data.table(x= 1:10,y= 1:10,z= 1:10, l = 11:20,d= 21:30)
  test&lt;-test[,..I:=.I]
  vec_of_names = c("z","l","d")
  
  function_test&lt;-function(x,y){
    sum(x)+y
  }
  
  vec_of_final_names&lt;-c("sum_z","sum_l","sum_d")
  </code></pre>
  
  <p>When I then attempt do to something like this:</p>
  
  <pre><code>for (i in 1:length(vec_of_names)){
    test&lt;-test[,vec_of_final_names[i]:=function_test(x=.SD,y=eval(parse(text=vec_of_names[i]))),.SDcols=c("x","y"),by=..I]
  }
  </code></pre>
  
  <p>I get an error:</p>
  
  <pre><code> Error in eval(expr, envir, enclos) : object 'z' not found 
  </code></pre>
  
  <p>Whereas code below works perfectly fine but is a little bit ugly and also slow. Maybe somebody can suggest better alternatives.</p>
  
  <pre><code>for (i in 1:length(vec_of_names)){
    test&lt;-test[,vec_of_final_names[i]:=function_test(x=eval(parse(text=paste("c(",paste(c("x","y"),collapse=","),")",sep=""))),y=eval(parse(text=vec_of_names[i]))),by=..I]
  }
  </code></pre>