When I want to create a new table in the new versions of data.table it generated an error which is annoying because I am logging errors and warnings in my shiny app
iris %>% setDT()
iris[,asdf:= '']
iris[,gsd:=character()]
iris[,':='(vik = character())]
All of these ways give me a warning message like this
> iris[,asdf:= '']
Error in assign(as.character(name), x, parent.frame(), inherits = TRUE) :
cannot change value of locked binding for 'iris'
In addition: Warning message:
In `[.data.table`(iris, , `:=`(asdf, "")) :
Invalid .internal.selfref detected and fixed by taking a (shallow) copy of the data.table so that := can add this new column by reference. At an earlier point, this data.table has been copied by R (or was created manually using structure() or similar). Avoid key<-, names<- and attr<- which in R currently (and oddly) may copy the whole data.table. Use set* syntax instead to avoid copying: ?set, ?setnames and ?setattr. If this message doesn't help, please report your use case to the data.table issue tracker so the root cause can be fixed or this message improved.
> iris[,gsd:=character()]
Error in assign(as.character(name), x, parent.frame(), inherits = TRUE) :
cannot change value of locked binding for 'iris'
In addition: Warning message:
In `[.data.table`(iris, , `:=`(gsd, character())) :
Invalid .internal.selfref detected and fixed by taking a (shallow) copy of the data.table so that := can add this new column by reference. At an earlier point, this data.table has been copied by R (or was created manually using structure() or similar). Avoid key<-, names<- and attr<- which in R currently (and oddly) may copy the whole data.table. Use set* syntax instead to avoid copying: ?set, ?setnames and ?setattr. If this message doesn't help, please report your use case to the data.table issue tracker so the root cause can be fixed or this message improved.
> iris[,':='(vik = character())]
Error in assign(as.character(name), x, parent.frame(), inherits = TRUE) :
cannot change value of locked binding for 'iris'
In addition: Warning message:
In `[.data.table`(iris, , `:=`(vik = character())) :
Invalid .internal.selfref detected and fixed by taking a (shallow) copy of the data.table so that := can add this new column by reference. At an earlier point, this data.table has been copied by R (or was created manually using structure() or similar). Avoid key<-, names<- and attr<- which in R currently (and oddly) may copy the whole data.table. Use set* syntax instead to avoid copying: ?set, ?setnames and ?setattr. If this message doesn't help, please report your use case to the data.table issue tracker so the root cause can be fixed or this message improved.
Please help if there is a new way to add an empty or normal column in a data.table