data.table 1.9.2中的分组意外行为当by是大数字时

时间:2014-03-23 08:11:30

标签: r grouping data.table

我发现当by由相当大的数字组成时, data.table 1.9.2 中的分组无法正常工作,正如这个小例子所示:

dt <- data.table("col1"=c(
                   20021821000066,
                   20021821000066,
                   20021820000040,
                   20021821000091,
                   20021821000277))

> dt[, .N, by=col1]
           col1 N
1: 2.002182e+13 4
2: 2.002182e+13 1

但是,当我第一次将by转换为字符向量时,一切正常:

> dt[, col1:=as.character(col1)]
> dt[, .N, by=col1]
             col1 N
1: 20021821000066 2
2: 20021820000040 1
3: 20021821000091 1
4: 20021821000277 1

我在以前版本的data.table中没有遇到过这个问题,例如data.table 1.8.10。

0 个答案:

没有答案
相关问题