gpt4 book ai didi

r - 使用 DPLYR full_join 连接 3 个大型数据帧时,如何修复错误:std::bad_alloc 消息?

转载 作者:行者123 更新时间:2023-12-05 07:18:13 25 4
gpt4 key购买 nike

我有 3 个非常大的文件,其中包含数千个观察结果(file_1 = 6314 行,file_2 = 11020 行,file_3 = 2757 行)。我需要加入他们,所以我使用了 dplyr 包中的函数 full_join()。当我运行代码时,我得到了这个错误:Error: std::bad_alloc 没有别的。

我该如何解决这个问题?

这是我的代码:

det = full_join(det1, det2, by = "collectioncode")
det = full_join(det, det3, by = "collectioncode")

最佳答案

我可能迟到了,但我遇到了类似的连接问题,这些问题不应该引起这些问题(因此我找到了这个线程)。然后我注意到,默认情况下,dplyr 的连接匹配 NA,这让我的数据集达到了数百万。我可以通过将 na_matches 设置为“从不”来解决我的问题,例如:

det = full_join(det1, det2, by = "collectioncode", na_matches="never")

希望这对您有所帮助!

关于r - 使用 DPLYR full_join 连接 3 个大型数据帧时,如何修复错误:std::bad_alloc 消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58454706/

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