附加到大型data.frame并达到内存限制

时间:2013-10-10 15:42:43

标签: r dataframe

我正在尝试将一个月的数据(200k)行附加到已经16m行的data.frame,并且我的系统上的内存限制达到了:

d = rbind(d, n)
Error: cannot allocate vector of size 60.8 Mb
In addition: Warning messages:
1: In rbind(deparse.level, ...) :
  Reached total allocation of 8072Mb: see help(memory.size)

memory.sizememory.max分别报告2187.88和8072,所以我想我正在使用我所有的8GB系统内存。使用JD Long in this question详述的对象记忆报告功能,我得到以下报告:

            Type          Size     Rows Columns
d     data.table 2,231,877,576 15941535      26
files  character           912       13      NA
i        numeric            48        1      NA
n     data.frame    28,176,000   213116      26

是否有另一种方法可以附加到data.frame,这种方式不会导致明显的对象重复似乎正在发生并占用内存?我希望避免附加到csv文件,因为我正在使用.RData保存的对象以便更快地读取数据。

1 个答案:

答案 0 :(得分:3)

如果您使用的是data.table个对象,则应使用rbindlist来避免对data.table制作不必要的副本。这应该有用......

d = rbindlist(d, n)