I am new to data.table and I have a problem with this class.
I have a table (data1) with two columns: pair and coefficient. A pair is the key of a data table.
I am trying to change a value in a table.
When I write the following code:
(cple is an existing value of Couple) data1[cple]$Ratio[1]<-0
The error seems to be related to the keys, but I canβt understand what?
The following is an example:
>data1<-data.table(Couple=c("a","a","b","b"),Ratio=1:4) >data1 Couple Ratio 1: a 1 2: a 2 3: b 3 4: b 4 >setkey(data1,Couple) >data1["a"]$Ratio[1]<-2
thanks
source share