Data.table - like any data.frame - this is a list of pointers to column vectors.
When creating new columns, we write jfrom DT[i,j,by]so that it evaluates the list of columns:
DT[, (newcol_names) := list(newcol_A, newcol_B)]
, list() OP, list.
data[,gearsL := list(list(unique(gear))), by=cyl]
.() :
data[, gearsL := .(list(unique(gear))), by=cyl]
, , .
. list()/.():
DT = data.table(id=1:3)
DT[, E := c(4,5,6)]
DT[, R := 3]
, E , R . :
DT[, Elist := list(hist(rpois(1,1)), hist(rpois(2,2)), hist(rpois(3,3)))]
E, Elist . ; list() , list,
sapply(DT, class)
# id E R Elist
# "integer" "numeric" "numeric" "list"
list()/.() : list, :
DT[, Rlist := list(c("a","b"))]
# based on the pattern for column R, this should work as if we typed
# Rlist := list(c("a","b"), c("a","b"), c("a","b"))
, C2 := .( c("a", "b") ) , , Elist. , list()/.():
DT[, Rlist := .(list(c("a","b")))]
OP, list()/.().