3

RStudio を使用して、ローカルの OpenCPU シングルユーザー サーバーをセットアップしました。また、単純な test.R ファイルのみを含む独自の R パッケージ (パッケージ名: test ) を作成します。ソースコードは

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"。そのようなスクリプトを実行できますか?

誰でもこれを手伝ってもらえますか?ありがとう。

4

1 に答える 1

1

R パッケージをインストールすると、配下のスクリプト/Rが関数/オブジェクトに変換されます。関数のソースを読み取るには、次のいずれかを実行します。

curl http://localhost:6067/ocpu/library/test/R/f1/print
curl http://localhost:6067/ocpu/library/test/R/f1/ascii
于 2014-02-07T22:09:05.973 に答える