我创建了小数据表DT = data.table(a=1:2, a=1:2).
如果我使用 names(DT) <- c("b","b")
我收到警告
In `names<-.data.table`(`*tmp*`, value = c("b", "b")) :
The names(x)<-value syntax copies the whole table. This is due to <- in R itself. Please change to setnames(x,old,new) which does not copy and is faster. See help('setnames'). You can safely ignore this warning if it is inconvenient to change right now. Setting options(warn=2) turns this warning into an error, so you can then use traceback() to find and change your names<- …Run Code Online (Sandbox Code Playgroud)