I needed to assign a \"second\" id to group some values inside my original id. this is my sample data:
dt<-structure(list(id = c(\"aaaa\", \"
Yes, the problem is the list. Here is a simple example:
DT <- data.table(1:5)
mylist1 <- list(DT,"a")
mylist1[[1]][,id:=.I]
#warning
mylist2 <- list(data.table(1:5),"a")
mylist2[[1]][,id:=.I]
#no warning
You should avoid copying a data.table into a list (and to be on the safe side I would avoid having a DT in a list at all). Try this:
f1 <- function(){
mylist <- list(res=data.table(id = c("aaaa", "aaaa", "aaas", "aaas", "bbbb", "bbbb"),
period = c("start", "end", "start", "end", "start", "end"),
date = structure(c(15401L, 15401L, 15581L, 15762L, 15430L, 15747L), class = c("IDate", "Date"))))
other_results <- ""
mylist$other_results <- other_results
mylist
}