I will answer this from the point of view of R. As a rule, you will have two problems:
1) Interaction with R, no matter where it works
2) Doing this from Geroku, where there is a special set of problems.
There are several general approaches to the first of them: you can use binding to R ( rsruby
, rinruby
, etc.), you can lay out on R (for example, from ruby โโR R -e "RCODEHERE"
), you can access to R as a web service (see the Rook
package, and in particular something like https://github.com/jeffreyhorner/rRack/blob/master/Rook/inst/exampleApps/RJSONIO.R ), or you can manually access R using something like rserve
.
Because of this, shelling the R is the easiest task if you just perform one operation and are not very concerned about performance. You will need to analyze the output that returns, but this is the fastest way for my work in one operation.
For more significant use, I would suggest using either one of the bindings, or configure R as a web service in another Heroku application and call it via HTTP.
The next task is to get R to work on Heroku - it is not available as part of the standard environment, and it is a read-only file system without root access, so you cannot just do sudo apt-get install
.
Itโs possible to sell R in REM - someone started doing it at https://github.com/deet-uc/rsruby-heroku , but I personally couldnโt get it working. It is also possible to build R directly on Heroku by installing all the dependencies, etc. is the approach I used at https://github.com/noahhl/rookonheroku (step 1 is all you need if you are not using Rook).
Note that Heroku may not allow you to deploy the second process in the same thread as your Rails application, which does most of the bindings. This can make these bindings difficult, so I tend to get around it in R or expose it to a web service and access it via HTTP.