Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to make a system command in fread() pass CRAN Windows checks? #1110

Closed
rmscriven opened this issue Apr 10, 2015 · 5 comments
Closed
Labels

Comments

@rmscriven
Copy link

Hi guys. I'm wondering if you can give me a push in the right direction. My package, retrosheet, fails Windows CRAN checks for r-release and r-oldrel, but passes the Windows r-devel check. Here are the check results.

http://cran.r-project.org/web/checks/check_results_retrosheet.html

The culprit line is on line 59 of

https://github.com/rmscriven/retrosheet/blob/master/R/getPartialGamelog.R

Specifically, CRAN reports the following,

Syntax error: end of file unexpected (expecting ")")
Warning: running command 'sh.exe -c (grep '20120825' GL2012.TXT) > D:\temp\RtmpC8Rfyr\file16485edb70d9' had status 2
Warning in shell(paste("(", input, ") > ", tt, sep = "")) :
 '(grep '20120825' GL2012.TXT) > D:\temp\RtmpC8Rfyr\file16485edb70d9' execution failed with error code 2
Error in fread(command, header = FALSE, select = sel) :
 File not found: D:\temp\RtmpC8Rfyr\file16485edb70d9
Calls: getPartialGamelog -> fread
Execution halted

I'm hoping you might be able to give me a few pointers on how to get the function to pass all Windows checks, as I am having trouble going about it.

Cheers.

@rmscriven rmscriven changed the title [Question] How to make a system command in fread() pass certain CRAN checks? [Question] How to make a system command in fread() pass CRAN Windows checks? Apr 10, 2015
@jangorecki
Copy link
Member

Did 1.0.0 version of your package pass cran check OK for those OSes?
You are using shell commands like grep which I believe is heavy OS dependent.

Can't help you much but I recommend to setup travis-ci, it helps quite a lot. Recently it gets native support for R which makes it much simpler to setup (example logR/.travis.yml).

Also you can link a line in file directly by adding #L59 to url: getPartialGamelog.R#L59

@rmscriven
Copy link
Author

After thinking about this, in long-run there will probably be more arguments added to getPartialGamelog() and a system command may complicate things. So for now I've decided to take the safe route and do some pre-processing on the file before calling fread().

@jangorecki - thanks for the tips, I'll definitely have a look at travis-ci.

Closing this issue.

@arunsrinivasan
Copy link
Member

Thanks for the report. I've tested this with R versions 3.0.3, 3.1.1 and 3.1.3, with data.table versions 1.9.2, 1.9.4 and 1.9.5 on windows 8.1, with corresponding Rtools versions.. Not able to reproduce at all.

I'll keep it open because the issue seems to be in fread.

@rmscriven
Copy link
Author

Thanks Arun. I wrote this temporary workaround for out.

out <- if(is.null(date)) {
    fread(fname, select = sel, header = FALSE)
} else if(is.character(date)) {
    ## get the first column only - this is the 'Date' column
    sc <- scan(fname, sep = ",", flush = TRUE, what = "", quote = "\"", quiet = TRUE)
    ## find rows of matched dates
    if(!length(wh <- which(sc == date))) {
        stop("invalid 'date' given")
    }
    ## read the file - selecting specified date and columns
    suppressWarnings(fread(fname, select = sel, header = FALSE, skip = min(wh)-1L, 
        nrows = diff(range(wh))))
}
## set the names
setnames(out, retrosheetFields$gamelog[sel])
## return the table
out

}

Obviously there are other checks that have to happen now, which I omitted. Unfortunately this is a lot slower than using the grep command.

@arunsrinivasan
Copy link
Member

Can't reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants