我试图合并两个数据框A和B.根据object_size()
,A有大约45,000行和25列,大小为7.39 MB。 B有大约122,000行和36列,但合并中只涉及2列。 B的大小为32.6 MB。这是我的合并代码:
A <- merge(x=A, y=B[,c("col1","col2")], by="col1", all.x=TRUE, all.y=FALSE)
当我尝试运行合并时:我收到以下错误消息:
Error: cannot allocate vector of size 6.6 Gb
In addition: Warning messages:
1: In merge.data.frame(x = bat.2007.2014, y = mlb.ebis.keys[, c("player_id", :
Reached total allocation of 12186Mb: see help(memory.size)
2: In merge.data.frame(x = bat.2007.2014, y = mlb.ebis.keys[, c("player_id", :
Reached total allocation of 12186Mb: see help(memory.size)
3: In merge.data.frame(x = bat.2007.2014, y = mlb.ebis.keys[, c("player_id", :
Reached total allocation of 12186Mb: see help(memory.size)
4: In merge.data.frame(x = bat.2007.2014, y = mlb.ebis.keys[, c("player_id", :
Reached total allocation of 12186Mb: see help(memory.size)
我正在运行Windows 10和R版本3.3.1(64位)。我的机器有12 GB的RAM。
这两个数据框似乎都是中等大小。为什么我的内存不足?
答案 0 :(得分:0)
如果检查通过合并您colnames,严丝合缝。我有一个类似的问题,很可能是这种内存分配异常的原因。是的,主元是应该总是唯一的。