Reputation: 61
I have a package 'soilreports' built in RStudio, and following the sound advice on https://r-pkgs.org/. The package produces the appropriate reports as pdfs in the expected folder. It uses the .Rmd file and applies the params.
When I install it in the /usr/local/lib/R/site-library (and restart apache2) to make it accessible by the opencpu server, it is available via the test page on my server, but it fails to run properly when I supply the params by POST.
The test page returns the error message "cannot open the connection In call: file(file, ifelse(append, "a", "w"))".
I interpreted the error as saying that the function cannot write to the working directory. To that directory added a group which contains the right user as I understand it and gave it write permission.
This has not solved it. In the test page when calling "../library/soilreports/R/pointreportgen" with the appropriate params and values, it still produces the error.
Despite much good advice, I am still missing something. I would greatly appreciate advice to interpret the error message and resolve the problem.
thanks David
Upvotes: 0
Views: 162
Reputation: 32978
Try copying the file to your current working directory and then invoking it.
pointreportgen <- function(sample_point_id,survey_id, farm_id){
rmdfile <- system.file("rmd", "point_soil_sample_report_params.Rmd", package = "soilreports")
file.copy(rmdfile, "input.rmd")
rmarkdown::render(input = "input.rmd", output_file = 'Point_Soil_Sample_Report.pdf', params = list(
sample_point_id = sample_point_id,
survey_id = survey_id,
farm_id = farm_id
))
}
Upvotes: 0