Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in R data.table v1.9.6 - function "fread"

I recently updated to data.table 1.9.6 and get the following error when using fread:

 fread("Aug14.csv")
Error in fread("Aug14.csv") : 
  4 arguments passed to .Internal(nchar) which requires 3

Another post discusses this error in another context, but this worked fine prior to upgrading to data.table 1.9.6. Any advice?

Here's my set up:

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] data.table_1.9.6 Matrix_1.2-2    

loaded via a namespace (and not attached):
[1] modeltools_0.2-21 tools_3.2.0       splines_3.2.0     grid_3.2.0        chron_2.3-47      stats4_3.2.0      lattice_0.20-33  
like image 580
JK_chitown Avatar asked Oct 02 '15 17:10

JK_chitown


1 Answers

This seems to be a wider problem affecting other packages too and something similar was raised on r-devel here :

http://r.789695.n4.nabble.com/Error-generated-by-Internal-nchar-disappears-when-debugging-td4713138.html

If I understand correctly, CRAN provides one Windows binary for the R 3.2.* series. I guess this binary is built using the latest version of R in that series, currently R 3.2.2. As Andriy T. pointed out in a comment here, the base R function nchar gained an extra argument in R 3.2.1. Since data.table uses the R function nchar and it sets ByteCompile:TRUE in its DESCRIPTION file, the CRAN binary package for Windows doesn't seem to be compatible with R 3.2.0. I guess binary incompatible changes to R itself are supposed to be made to the .0 version only for this reason, but I'm not sure on that. Where packages are compiled on install (e.g. Ubuntu) this isn't an issue.

If you are using R < 3.2.0 on any platform, there shouldn't be a problem.

If you are using R >= 3.2.1 on any platform, there shouldn't be a problem.

If you are using R 3.2.0 on Windows and installing the binary .zip from CRAN (i.e. the default method) then you'll need to either upgrade to R >= 3.2.1, or, build data.table (and potentially any other package using nchar that also set ByteCompile:TRUE) yourself using Rtools.

like image 54
Matt Dowle Avatar answered Sep 29 '22 17:09

Matt Dowle