R data.table 1.9.2 关于 setkey 的问题

标签 r data.table

这似乎是一个在 1.8.10 之后引入的与包含列表的带有 DT 的 setkey 相关的错误。
运行以下两个代码以查看问题:

library(data.table)
dtl <- list()
dtl[[1]] <- data.table(scenario = 1,
                       processing = c(function(x) x))
dtl[[2]] <- data.table(scenario = 2,
                       processing = c(function(x) x))
dt <- rbindlist(dtl)
setkeyv(dt, c("scenario"))

下面的第二个,目前产生错误:
dtl <- list()
dtl[[1]] <- data.table(scenario = 2, # <- note we change order
                       processing = c(function(x) x))
dtl[[2]] <- data.table(scenario = 1,
                       processing = c(function(x) x))
dt <- rbindlist(dtl)
setkeyv(dt, c("scenario")) #setkey cannot sort?

它在 1.8.10 中运行良好。我无法在我的 DT 上设置键,似乎与包含函数列表的 DT 有关。有什么简单的解决方法吗?我将错误消息跟踪到 C 代码,但不知道如何修复它。

R 3.0.2 + data.table 1.9.2 在 Windows 64 位
谢谢

最佳答案

现在已在 v1.9.3(当前开发版本)的 commit #1216 中修复。来自 NEWS :

setkey doesn't allow list columns as keys. However, a bug in setkey did not allow setting key on data.table just containing list columns. This is now fixed. Closes #5366. Thanks to James Sams for reporting and to Michael Nelson for pinpointing the issue with a minimal reproducible example. Also thanks to MusX for reporting on SO.



我们应该很快将 1.9.4(下一个稳定版本)推送到 CRAN。

关于R data.table 1.9.2 关于 setkey 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22186798/

相关文章:

r - 在 j 中使用大括号 {...}

r - ggplot scale_continuous expand 参数如何工作?

R data.table 点积与匹配的列名(每组)

r - fread 系统区域设置错误

r - 为什么按组 mutate() 需要永远?

r - 在将列表转换为数据框或数据表时处理丢失的信息

r - R Selenium 中的 OpenFileDialog

r - 将统计信息附加到 coeftest 输出以包含在观星者表中

r - 如何在 kernlab 包的 ksvm 中自定义内核函数?

r - 将名为List的混合长度转换为data.frame