Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 r 中使用 2 个数据帧,当我尝试合并它们时出现错误:错误:无法分配大小为 565.3 Mb 的向量
如果我检查: memory.limit()
memory.limit() [1] 1.759219e+13
我的电脑 8GB 内存。
我该怎么做才能解决这个问题??
如果您需要在 R 中合并大型数据帧,一个不错的选择是分块进行,例如 10000 行。如果您要合并数据帧 x 和 y,请循环 10000 行 x 片段,与 y 合并(或者更确切地说使用 plyr::join)并立即将这些结果附加到一个单独的 csv 文件中。将所有片段合并并写入文件后,读取该 csv 文件。通过正确使用逻辑索引向量和正确放置的 rm 和 gc 调用,这非常节省内存。虽然它并不快。