data.table错误,导致R中的segfault [英] data.table bug, causing a segfault in R
本文介绍了data.table错误,导致R中的segfault的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码将我的 R 2.15.0
隔离,运行 data.table 1.8.9
。
The following code segfaults my R 2.15.0
, running data.table 1.8.9
.
library(data.table)
d = data.table(date = c(1,2,3,4,5), value = c(1,2,3,4,5))
# works as expected
d[-5][, mean(value), by = list(I(as.integer((date+1)/2)))]
# crashes R
d[-5, mean(value), by = list(I(as.integer((date+1)/2)))]
不同的输出:
d[-5][, value, by = list(I(as.integer((date+1)/2)))]
# I value
# 1: 1 1
# 2: 1 2
# 3: 2 3
# 4: 2 4
d[-5, value, by = list(I(as.integer((date+1)/2)))]
# I value
# 1: 1 2.121996e-314
# 2: 1 2.470328e-323
# 3: 2 3.920509e-316
# 4: 2 2.470328e-323
更简单的命令会从评论中崩溃我的 R
:
Simpler command crashing my R
from the comments:
d[-5, value, by = date]
正如里卡多指出的,它是负面索引和的组合造成的问题。
As Ricardo points out, it's the combination of negative indexing and by
that creates the problem.
推荐答案
更新:这已经修复在v1.8.11。从新闻:
UPDATE: This has been fixed in v1.8.11. From NEWS :
在i中具有负索引的崩溃或不正确的聚合结果是固定的,#2697 。
感谢Eduard Antonyan(eddi)的报告。已添加测试。
Crash or incorrect aggregate results with negative indexing in i is fixed, #2697. Thanks to Eduard Antonyan (eddi) for reporting. Tests added.
这篇关于data.table错误,导致R中的segfault的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文