> str(t2)
Classes ‘data.table’ and 'data.frame': 15349956 obs. of 2 variables:
$ id :Class 'integer64' num [1:15349956] 4.26e-319 4.26e-319 4.26e-319 4.26e-319 4.26e-319 ...
$ category: int 706 706 706 706 706 706 706 706 706 706 ...
- attr(*, ".internal.selfref")=<externalptr>
- attr(*, "sorted")= chr "id" "category"
> dput(head(t2))
structure(list(id = structure(c(4.26111856912241e-319, 4.26111856912241e-319,
4.26111856912241e-319, 4.26111856912241e-319, 4.26111856912241e-319,
4.26111856912241e-319), class = "integer64"), category = c(706L,
706L, 706L, 706L, 706L, 706L)), .Names = c("id", "category"), sorted = c("id",
"category"), class = c("data.table", "data.frame"), row.names = c(NA,
-6L))
> head(t2)
id category
1: 86246 706
2: 86246 706
3: 86246 706
4: 86246 706
5: 86246 706
6: 86246 706
> t2[J(86246,706), nomatch=0]
Empty data.table (0 rows) of 2 cols: id,category
为什么二分查找找不到我们在 t2 head 中看到的行?
最佳答案
现在已在 v1.9.3 中实现(可从 R-Forge 获取),请参阅 NEWS :
o
bit64::integer64
now works in grouping and joins, #5369. Thanks to James Sams for highlighting UPCs and Clayton Stanley.
Reminder:fread()
has been able to detect and readinteger64
for a while.
关于上面OP的例子:
t2[J(as.integer64(86246),706), nomatch=0L]
# id category
# 1: 86246 706
# 2: 86246 706
# 3: 86246 706
# 4: 86246 706
# 5: 86246 706
# 6: 86246 706
关于R数据表二分查找未找到行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23564849/