简体   繁体   English

我在 Opencpu 服务器上运行的 package 出错

[英]error on my package run in Opencpu server

I have a package 'soilreports' built in RStudio, and following the sound advice on https://r-pkgs.org/ .我有一个 package 内置于 RStudio 的“土壤报告”,并遵循https://r-pkgs.org/上的合理建议。 The package produces the appropriate reports as pdfs in the expected folder. package 在预期的文件夹中以 pdf 格式生成适当的报告。 It uses the.Rmd file and applies the params.它使用 .Rmd 文件并应用参数。

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.当我将它安装在 /usr/local/lib/R/site-library(并重新启动 apache2)以使其可以被 opencpu 服务器访问时,它可以通过我服务器上的测试页面获得,但是当它无法正常运行时我通过 POST 提供参数。

The test page returns the error message "cannot open the connection In call: file(file, ifelse(append, "a", "w"))" .测试页面返回错误信息“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.我将错误解释为 function 无法写入工作目录。 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.在使用适当的参数和值调用“../library/soilreports/R/pointreportgen”时的测试页面中,它仍然会产生错误。

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谢谢大卫

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
  )) 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM