我使用RStudio设置了本地OpenCPU单用户服务器。我还创建了自己的R包(包名称:test),其中仅包含一个简单的test.R文件。源代码是
f1 <- function(x, y) {x+y}
我通过library(opencpu)
在RStudio的控制台中键入来启动OpenCPU服务器。我得到了以下印刷品。
Initiating OpenCPU server...
OpenCPU started.
[httpuv] http://localhost:6067/ocpu
OpenCPU single-user server ready.
我可以通过键入运行脚本curl http://localhost:6067/ocpu/library/test/R/f1 -d "x=33&y=3"
。
但是,当我尝试通过键入显示R脚本(test.R)时curl http://localhost:6067/ocpu/library/test/R/test.R
,它会打印
object 'test.R' not found
In call: get(reqobject, paste("package", reqpackage, sep = ":"), inherits = FALSE)
另外,通过键入来运行test.R脚本时,它失败了curl http://localhost:6067/ocpu/library/test/R/test.R -X POST -d "x=3&y=4"
。我可以像这样运行脚本吗?
有人可以帮忙吗?谢谢。
当您安装R软件包时,下面的脚本/R
将变成函数/对象。要阅读函数的源代码,只需执行以下操作:
curl http://localhost:6067/ocpu/library/test/R/f1/print
curl http://localhost:6067/ocpu/library/test/R/f1/ascii
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句