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?
+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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With