You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
updating data.table by reference has side effect of altering other non-data.table objects #5756
If we assign a data.table's names to an R variable, then update the data.table columns by reference (with :=) the R object that stored the original names also (surprisingly) gets updated by reference. This does not seem to be desired behaviour to me. Especially as the use case where I discovered this was when trying to save the column names before alteration for later use.
We can work around this issue by using xnames = copy(names(x)), however the fact that updating a data.table by reference has this side effect is probably best avoided in the first place.
Activity
AngelFelizR commentedon Nov 24, 2023
I agree, that behavior can be problematical.
jangorecki commentedon Nov 24, 2023
isn't this documented enough? did you look for duplicated issues before reporting?
I bet there is code that relies on that behavior and we cannot really change that without incrementing data.table version to 2.0.0
jangorecki commentedon Nov 24, 2023
https://cloud.r-project.org/web/packages/data.table/vignettes/datatable-reference-semantics.html
#4573 #1824 #2136 #3316
adding this to 2.0.0 milestone, which possibly may never happen