Ignore safety check when using setnames
data.table, r
Solution
+1 Now fixed in v1.8.11. From NEWS :
setnames(DT,"oldname","newname") no longer complains about duplicated column names in DT so long as oldname is unique and unambiguous. Thanks to Wet Feet for highlighting.
Problem
``` DT<-data.table(a=1,b=2,a=3) DT # a b a #1: 1 2 3 setnames(DT,"b","c") #Error in setnames(DT, "b", "c") : # 'old' is character but there are duplicate column names: a ``` In the example above, you can see that I wish to change the header of a column that is not duplicated, but `setnames` prevents me from doing so. Is there a way to ignore the check, as the column header I am changing is not duplicated?