Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

integrating R with Rsruby

I was wondering if anyone possibly had any experience integrating R into Rails, specifically, on heroku. I am familiar with the rsruby gem, which is the de facto (perhaps only) binding that ruby has with R, but documentation on integrating R with Rails is sparse if not nonexistent. Would it be feasible to, let's say, install R into the lib folder of a Rails application and use rsruby to access it through Rails?

like image 604
Han Avatar asked Aug 21 '11 00:08

Han


3 Answers

I use Rserve with a wrapper which simplifies the interface, called Rserve-simpler.
http://rubygems.org/gems/rserve-simpler . It makes my life easier. I end up using R and Ruby together quite often.

Here is a question where I've explained some usage. How to pass a ts object to R via RSRuby

like image 134
Ryanmt Avatar answered Oct 22 '22 14:10

Ryanmt


I created a Heroku Buildpack to make using R on Heroku a no-brainer.

Checkout the heroku-buildpack-r for details.

like image 2
VirtualStaticVoid Avatar answered Oct 22 '22 13:10

VirtualStaticVoid


I explored R/Rails integration a couple of years ago, so my posts will be out of date by now. However, they're still available and might be useful if you want to read them:

RSRuby and Rails revisited.

One issue I encountered was a "stack smashing error" on terminating the development server, which made me nervous as to whether the project was worth pursuing.

I have not tried deployment to Heroku. In principle, I like your idea of putting R in the Rails lib/, but I'm not sure if it would work.

In general, I find that bridging other languages with R is troublesome. It might be better to keep the two separate, by running R on a server (using e.g. RApache) and passing data back/forth between that and the Rails app (e.g. as JSON). Another post that I wrote on that idea:

Getting your web application and R(Apache) to talk to each other

like image 1
neilfws Avatar answered Oct 22 '22 13:10

neilfws