5

我正在尝试将几个文件合并到一个主文件中。有 5 个结构相同的文件,我可以将每个文件单独读入一个数据框中,没有问题。我什至为 200 多个变量手动设置列类,而不是让 R 决定,因为我认为这是导致问题的原因。但是,将任何两个文件附加在一起会导致我的内存不足。

警告消息:1:在 rbind(deparse.level, ...) 中:达到 4043Mb 的总分配:请参阅帮助(memory.size)

所以我做了一些实验:我将文件 1 的两个不同块连接在一起。这样可行。我将文件 2 的一部分加入到文件 1 的一部分中。这行得通。我将文件 2 的一部分加入到原始文件 1 中。这行得通。

这些文件中的每一个都小于 200MB,所以我不确定我是否应该耗尽内存。如果有人感兴趣,数据来自hearstchallenge.com。竞争早已结束,我们只是将数据用于分析实验(而不是编程!)。

关于如何解决这个问题的任何建议?

4

1 回答 1

1

I have run into similar problems. The solution is not to use rbind() or cbind() on large data. They tend to leak memory.

To solve your problem using only R, first create a dataframe of the dimensions that the dataframe would have after you put the pieces together. Then use assignments to fill in the large dataframe.

于 2013-03-21T20:29:12.170 回答