当尝试使用data.table 1.9.4获取字符向量的最小值时,我收到以下错误:
Type 'character' not supported by GForce min (gmin).
Either add the prefix base::min(.) or turn off
GForce optimization using options(datatable.optimize=1)
很公平,但这打破了我现有的很多代码!我可以使用options(datatable.optimize=1)
关闭此优化。不管怎么说,如果base::min
只使用is.character == TRUE
,还是GForce优化呢?
答案 0 :(得分:1)
在commit 1734的data.table v1.9.5中实施。
require(data.table) ## 1.9.5
set.seed(1L)
DT = data.table(x=sample(3,10,TRUE), y=sample(letters[1:3], 10,TRUE))
options(datatable.verbose=TRUE)
DT[, .(min(y), max(y)), by=x]
# Detected that j uses these columns: y
# Finding groups (bysameorder=FALSE) ... done in 0secs. bysameorder=FALSE and o__ is length 10
# lapply optimization is on, j unchanged as 'list(min(y), max(y))'
# GForce optimized j to 'list(gmin(y), gmax(y))'
# x V1 V2
# 1: 1 a c
# 2: 2 a c
# 3: 3 b c
如果事情不对,请回信。