I have been encountering some problems when trying to get R to output content to a file from within my laravel app.
Scenario where output works
When i call my R script from the command line like so:
vagrant@homestead:~/path/to/my-laravel-project/storage/marker$ Rscript marker.R --assessment=123456 --host=127.0.0.1 --user=homestead --pass=secret --db=db_name
I can get output either to the command line or to a file using sink commands:
zz <- file("r_out.txt", open = "wt")
sink(zz)
sink(zz, type = "message")
sink(type = "message")
...
sink()
or even just
sink("r_out.txt", append=FALSE, split=TRUE)
Scenario where output is missing
However, when i call the R script from within my application using an api call like so:
http://ift.tt/2c00EYE
The R script runs but fails to write to the output file at all.
Additional Notes
- The output file is in the same directory as the R script
- The file permissions are 775 and the file is writeable
- Both the R script and the output file are within the laravel storage directory
- The R script does everything else (i.e. it marks my assessments) but it does not write to the file
- There are no errors being returned from the R script when it is run
- The environment this has been developed on is a
laravel/homestead
vagrant box with all of the standard R script packages for R and RMySQL installed manually
My question is this: Why would R sink() work on the command line but not when called from within my application?
Any help would be very much appreciated!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire