In below example, I need to assign a list to a data.table's variable code, so that value list(11,22) is assigned to dt$code. How do I do that?
dt <- data.table(1:3)
dt$code <- list()
dt[V1==2, code:=list(11,22)] # does not work
dt[V1==2, code:=.(list(11,22))] # does not work
My question is simpler and shorter than in the earlier post. Thanks for the answer:
dt[V1==2, code:=list(list((list(11,22)))] # works !
dt[V1 == 2, code := list(list(list(11, 12)))]. possible duplicate of stackoverflow.com/questions/22531477/…