R data.table 1.9.2关于setkey的问题 [英] R data.table 1.9.2 issue on setkey

查看:75
本文介绍了R data.table 1.9.2关于setkey的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

It seems to be a bug introduced post 1.8.10 related to setkey with DT which contains lists. Run two below codes to see the issue:

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"))

以及下面的第二个当前产生错误:

and second below, currently produce error:

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代码,但不知道如何解决。

It was working well in 1.8.10. I'm not able to setkey on my DT, seems to be related to DT which contains list of functions. Any easy workaround? I track the error msg to C code but have no idea how to fix it.

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

R 3.0.2 + data.table 1.9.2 on windows 64bit Thanks

推荐答案

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



This is now fixed in commit #1216 of v1.9.3 (the current development version). From NEWS:


setkey 不允许将列表列作为键。但是, setkey 中的错误不允许在 data.table 仅包含上设置键列出列。现在,此问题已解决。关闭#5366。感谢James Sams的报告,并感谢Michael Nelson给出了一个最小的可复制示例来指出问题。同样感谢MusX的有关SO的报告。 / p>

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。

We should be pushing 1.9.4 (next stable release) to CRAN sometime soon.

这篇关于R data.table 1.9.2关于setkey的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆