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

1

10

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  
Aphra answered 2/10, 2015 at 17:4 Comment(12)
One of my colleagues saw this error too after updating data.table. It was fixed by updating R. I should probably have reported it, but didn't have the time to investigate.Baten
Ok good @Baten - I'm glad someone else is seeing this - my problem is I can't update R fast enough (IT policy - arrrgh!) so I was hoping there was some other soution.Aphra
@user2642948 You did not provide reproducible example. Also please update title of your question pointing at least the function name which you are asking about. This way it can be easier to find for any future searches.Ranch
Odd. I only this morning commented on the other question from June. I figured it was fixed but filed #1370 to double check.Nationwide
Is it possible you have 2 R libraries in your path and somehow the old version is still knocking around. We notice you're on Windows. Clean out old .dll and reinstall data.table. Also reboot to clear zombie processes holding a lock on the old .dll. I've seen that before on Windows. Note the other report was also Windows.Nationwide
#31142780Nationwide
@MattDowle - Thanks - I've rebooted, re-installed R 3.2.0 (deleted everything including the leftover library directory), but I still get the error. I'll keep at it - and yes, Windows....never a problem on my Linux box at home....Aphra
Thanks for update. That's really odd. I'm at a loss then. Anything in your .Rprofile picking up some other library? Checked .libPaths()? I guess it's possible there is a real problem that only shows on Windows. But it works for other people on Windows (and on win-builder) so there's a some difference between you and them.Nationwide
Could it be something in your Aug14.csv file; e.g. does it work with a trivial file? If so, run again with verbose=TRUE and report the output. Maybe it's an fread only problem, only with this file and possibly only on windows. What does test.data.table() return?Nationwide
@MattDowle: here's what I get with test.data.table():Aphra
> test.data.table() Running C:/Program Files/R/R-3.2.0/library/data.table/tests/tests.Rraw Loading required package: plyr Loading required package: ggplot2 Loading required package: hexbin Loading required package: nlme Loading required package: bit64 Loading required package: gdata Loading required package: GenomicRanges Loading required package: caret Loading required package: knitr Loading required package: plm Running test id 0 Error in setkeyv(x, cols, verbose = verbose, physical = physical) : 4 arguments passed to .Internal(nchar) which requires 3 There were 11 warningsAphra
Thanks. Please type nchar at the prompt. Is it a call with 4 arguments: .Internal(nchar(x, type, allowNA, keepNA)) and does find("nchar") return "package:base" ?Nationwide
N
16

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.

Nationwide answered 5/10, 2015 at 23:11 Comment(1)
a-ha! Thanks so much for the follow up - I haven't been able to get back to this until today; upgraded to R 3.2.2 and now I'm back to data.table goodness. Good to know nchar has changed too..I use that function a bit...Thx!Aphra

© 2022 - 2024 — McMap. All rights reserved.