0
我有一個包含4個變量的數據表。我如何使用索引添加兩列。使用data.table中的索引添加兩列R
舉個例子:
DT = data.table(a=6,b=8,c=0,d=5)
min1 = 3
min2 = 4
DT[,"mrg":=min1+min2,with=F] # How to write this line correctly
DT[,(c(min1,min2)):=NULL] # this works
它一般不提倡用數字來指代的cols。例如,請參閱常見問題https://rawgit.com/wiki/Rdatatable/data.table/vignettes/datatable-faq.html中第一個問題的答案 – Frank