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
which should work just fine, except it doesn't on v3.1+. It works just fine with < v3.1. This is because R v3.1+ shallow copies where ever possible as opposed to deep copies and data.table will have to ake care of this. Here's a simple way to reproduce the issue:
# R v3.1.1
require(data.table)
dt= data.table(x=1:5, y=6:10)
ll= vector("list", 2L)
names(ll) <- c("a", "b")
ll$a=1L; ll$b=dtidx= c(FALSE, TRUE)
colnames(ll$b)[idx] ="bla"
names(dt) # [1] "x" "bla"
names(ll$b) # [1] "x" "bla"
The function colnames<- simply calls names(x) <- value which then calls the appropriate data.table method that uses setnames. However, x has only been shallow copied, on which we set names by reference, and hence the issue.
Submitted by: Arun ; Assigned to: Nobody; R-Forge link
As illustrated here on SO.
The text was updated successfully, but these errors were encountered: