3

I set up a local OpenCPU single-user server using RStudio. I also create my own R package(Package name: test) which includes only a simple test.R file. The source code is

f1 <- function(x, y) {x+y}

I started the OpenCPU server by typing library(opencpu) in RStudio's console. I got the following print.

Initiating OpenCPU server...
OpenCPU started.
[httpuv] http://localhost:6067/ocpu
OpenCPU single-user server ready.

I was able to run the script by typing curl http://localhost:6067/ocpu/library/test/R/f1 -d "x=33&y=3".

But when I tried to display the R script(test.R) by typing curl http://localhost:6067/ocpu/library/test/R/test.R, it printed

object 'test.R' not found

In call: get(reqobject, paste("package", reqpackage, sep = ":"), inherits = FALSE)

In addition, It's failed when I ran the test.R script by typing curl http://localhost:6067/ocpu/library/test/R/test.R -X POST -d "x=3&y=4". Could I run the script like that?

Could anyone help with this? Thanks.

wei
  • 213
  • 4
  • 13

1 Answers1

1

When you install the R package, scripts under /R are turned into functions/objects. To read the source of the function, just do on of these:

curl http://localhost:6067/ocpu/library/test/R/f1/print
curl http://localhost:6067/ocpu/library/test/R/f1/ascii
Jeroen Ooms
  • 31,998
  • 35
  • 134
  • 207
  • thanks. After I typed `curl https://public.opencpu.org/ocpu/library/utils/R/read.csv -F "file=@mydata.csv"`, and I checked the source code of utils package, I didn't find any string of `read.csv`. Where is this object? – wei Feb 13 '14 at 19:33
  • Can you move this conversation to the opencpu mailing list? – Jeroen Ooms Feb 13 '14 at 19:44
  • Ok. I'll move this to the mailing list. – wei Feb 13 '14 at 20:55