gpt4 book ai didi

r - 使用 setnames 时忽略安全检查

转载 作者:行者123 更新时间:2023-12-04 06:19:19 26 4
gpt4 key购买 nike

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

在上面的示例中,您可以看到我希望更改不重复的列的标题,而是 setnames阻止我这样做。有没有办法忽略检查,因为我正在更改的列标题没有重复?

最佳答案

+1 现在已在 v1.8.11 中修复。来自 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.

关于r - 使用 setnames 时忽略安全检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20942905/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com