If I have my own server with OpenCPU running, and an OpenCPU application installed, how do I allow it to use custom methods that I wrote? What I'm doing now is creating /R/method.R, generating documentation with doxygen, and then calling the method with the JS lib, but it can't seem to find the method. Visiting localhost/ocpu/library doesn't show the method name in the list either. Any suggestions?
Asked
Active
Viewed 54 times
0
-
1Are you exporting the function from your package via the namespace? – Jeroen Ooms Aug 15 '15 at 16:01
-
@Jeroen, I think I am, yes - visiting `localhost/ocpu/library/MyApp/NAMESPACE` shows `export(myfn)`, so I'm guessing I've done that right? – vinit_ivar Aug 15 '15 at 18:44
-
In that case it should show up at `localhost/ocpu/library/MyApp/R/myfn`. Make sure you press CTRL+R in your browser to force a refresh so that you are not looking at a cached version. – Jeroen Ooms Aug 15 '15 at 21:04
-
@Jeroen, okay, I think I see what the problem is - the browser is searching at `localhost/ocpu/library/R/myfn` rather than `localhost/ocpu/library/MyApp/R/myfn`. Have I done something wrong within the JavaScript itself? – vinit_ivar Aug 16 '15 at 07:05
-
1By convention, the opencpu library assumes that your webapp is within a subdir such as `www` (it has `r_path.href = "../R"`). You can change this using the `ocpu.seturl()` method. See also the comments in the source: https://github.com/jeroenooms/opencpu.js/blob/gh-pages/opencpu-0.5.js – Jeroen Ooms Aug 16 '15 at 09:45
-
Cheers, moving the webapp to `/inst/www` works. – vinit_ivar Aug 16 '15 at 15:34