I can't figure out how to do the following, crating a dynamic number of columns from a column of lists with data.table
set.seed(123); N=1e5
DT = data.table(x=rnorm(N), y=sample(c('a','b','c'),N,T))
probs = seq(.1,1,.1); newCols <- paste("q",100*probs,sep="");
DT2 <- DT[ ,list(Q=list(quantile(x,probs=probs))),by=y]
DT2
# y Q
#1: b -1.2817037351734,-0.840293441466144,-0.525195748246148,-0.259574774974136,
#2: c -1.26975023312311,-0.832359658553173,-0.513320691339448,-0.247863323660894,
#3: a -1.28189935066568,-0.838918942382995,-0.522409189372727,-0.257356179072232,
#Here I want to create 10 columns from Q called q10, q20...
DT2[ , newCols:=Q] #can't make this work because it is evaluated in the wrong environment I guess
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…