参考这篇帖子,我有另一个关于data.table
中列表列的问题。
DT = data.table(x=list(c(1,2),c(1,2),c(3,4,5)))
看起来您无法按列表列进行键控。
DT[,y:=.I,by=x]
Erreur dans `[.data.table`(DT, , `:=`(y, .I), by = x) :
The items in the 'by' or 'keyby' list are length (2,2,3). Each must be same length as rows in x or number of rows returned by i (3).
我以为只要列表长度相同就可以,但实际上:
DT = data.table(x=list(c(1,2),c(1,2),c(3,5)))
DT[,y:=.I,by=x]
Erreur dans `[.data.table`(DT, , `:=`(y, .I), by = x) :
The items in the 'by' or 'keyby' list are length (2,2,2). Each must be same length as rows in x or number of rows returned by i (3).
有没有解决方法?如果没有,那提出一个功能请求呢?
list
作为关键列。当您执行setkey(DT, "x")
时会收到此消息。 - Arun