[datatable-help] Adding Column to Data.Table not working

bgoldstein ben.goldstein at gmail.com
Tue Apr 1 18:56:58 CEST 2014


Up until a recent update (now 1.8.8) I would add a column to a DT the DF way:

DT <- data.table(a=c(1,2,3), b=c(4,5,6)) 
DT$c <- c(7:9)

Or I could have done the DT way:
DT[,c:=c(7:9)] 

However when I try to do this now I get the error:

> DT$c = c(7:9)
Error in `[<-.data.table`(x, j = name, value = value) : 
  attempt to set index 2/2 in SET_STRING_EL

I can hack around this by doing:

c <- 7:9
DT <- cbind(DT,c)

However, this does not seem desirable and is causing me to fix a lot of
code.

Is this a bug or am I doing something wrong now?

Thanks,

bg




--
View this message in context: http://r.789695.n4.nabble.com/Adding-Column-to-Data-Table-not-working-tp4687970.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list