带有data.table的setkeyv中的异常错误

时间:2015-06-30 15:20:49

标签: r data.table

我自己对data.table非常熟悉,但在setkeyv函数中遇到了一个我无法解决的奇怪错误。

错误非常简单:

keycols<-c("A", "B")
DT <- data.table(A=1:10, B=91:90)
setkeyv(DT, keycols)
# Error in setkeyv(x, cols, verbose = verbose, physical = physical) : 
#   4 arguments passed to .Internal(nchar) which requires 3

供参考,这是我的sessionInfo()

R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] cvTools_0.3.2     robustbase_0.92-4 lattice_0.20-31   kernlab_0.9-20    rstan_2.6.0       inline_0.3.14     Rcpp_0.11.6       data.table_1.9.4 

loaded via a namespace (and not attached):
 [1] chron_2.3-47   grid_3.2.0     plyr_1.8.3     stats4_3.2.0   magrittr_1.5   stringi_0.5-4  reshape2_1.4.1 tools_3.2.0    stringr_1.0.0 
[10] DEoptimR_1.0-2

1 个答案:

答案 0 :(得分:10)

我没有解释为什么会出现这种情况,但升级到R 3.2.1并安装每个软件包的最新版本可以解决问题。作为参考,这是我更新后的sessionInfo()

R version 3.2.1 (2015-06-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] kernlab_0.9-20    rstan_2.6.0       inline_0.3.14     Rcpp_0.11.6       cvTools_0.3.2     robustbase_0.92-4 lattice_0.20-31   data.table_1.9.4 

loaded via a namespace (and not attached):
 [1] chron_2.3-47   grid_3.2.1     plyr_1.8.3     stats4_3.2.1   magrittr_1.5   stringi_0.5-4  reshape2_1.4.1 tools_3.2.1    stringr_1.0.0 
[10] DEoptimR_1.0-2