I am a new user of the data.table package in R. I am trying to give a name to the new column created by a \"group by\" command
> DT = data.table(x=rep(c(\
DT[,list(z=sum(y)+3,a=mean(y*z)),by=x]
x z a
1: a 6 9
2: b 15 60
Since you are new to data.table, I recommend that you also study the help page of the setnames function as well as ?data.table and the data.table vignettes.
For conciseness, you can now use .() instead of list()
DT[, .(z=sum(y)+3, a=mean(y*z)), by=x]