【问题标题】:Appending to large data.frame and hitting memory limit附加到大型 data.frame 并达到内存限制
【发布时间】:2013-10-10 15:42:42
【问题描述】:

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

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.size 和 memory.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 保存的对象以更快地读取数据。

【问题讨论】:

    标签: r dataframe


    【解决方案1】:

    如果您使用data.table 对象,则应使用rbindlist 以避免不必要地复制您的data.table。这应该工作......

    d = rbindlist(d, n)
    

    【讨论】:

      猜你喜欢
      • 2011-09-11
      • 2012-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多