<div dir="ltr"><div><div><div><div>Hello,<br><br></div>I'm a huge fan of data.table and use it almost exclusively. I've not used this mailing list before, but I signed up to report an error I encountered because the error message asked me to.<br><br></div>I have a fairly large data.table (480,000 rows) with over 6,000 unique dates. I can create a factor version of the date variable using the := syntax, but not with set(), which I generally try to use as per the recommendation in the package documentation. Factoring a date column with set() does work for smaller data.tables though. See below.<br><br>Note that in addition to using as.factor(BigDT[["Date"]]) I used BigDT[,Date] and also tried creating the vector outside of set(), which works, but when I feed it to set it does not work.<br><br></div>Best,<br><br></div>Zach<br><div><div><div><div><div><br>> TestDT<-data.table(x=1:10,Date=seq(as.Date("2012-01-01"),as.Date("2012-01-10"),by="1 day"))<br>> set(TestDT,NULL,"DateFactor",as.factor(TestDT[["Date"]]))<br>> set(BigDT,NULL,"DateFactor",as.factor(BigDT[["Date"]]))<br>Error in set(BigDT, NULL, "DateFactor", as.factor(BigDT[["Date"]])) : <br>  Internal error, please report (including result of sessionInfo()) to datatable-help: oldtncol (0) < oldncol (41) but tl of class is marked.<br>> BigDT[,DateFactor:=as.factor(Date)]<br>> nrow(BigDT)<br>[1] 480743<br>> nlevels(BigDT[["DateFactor"]])<br>[1] 6119<br>> sessionInfo()<br>R version 3.2.1 (2015-06-18)<br>Platform: x86_64-pc-linux-gnu (64-bit)<br>Running under: Debian GNU/Linux stretch/sid<br><br>locale:<br> [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 <br> [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       <br><br>attached base packages:<br>[1] stats     graphics  grDevices utils     datasets  methods   base     <br><br>other attached packages:<br>[1] data.table_1.9.6<br><br>loaded via a namespace (and not attached):<br>[1] tools_3.2.1  chron_2.3-47<br><br></div></div></div></div></div></div>