AlexG wrote:
> Hi,
>
> I'm interested in making (well using, but I might be prepared to make)
> a bridge between Ruby and R. The RSPerl and RSPython packages seem to
> do pretty much what I want to do (in Perl and Python).
>
> My first question is does such a thing already exist? I could only find
> ruby-rmathlib (a wrapper for some of the math functions included in R)
> on the RAA and nothing on rubyforge. For obvious reasons searching for
> 'R' related topics is always difficult so I may well have missed
> something.
>
> I've a basic proof of concept (adapted from the RSPerl source code)
> (provisionally called rruby) where by:
>
> require "rruby"
> RRuby.new.eval_R("print","me")
>
> Does what you would expect (fires up an embedded R interpeter and
> prints "me"), and it seemed simple enough that I thought someone else
> might have already done this and had some more advanced code that I
> could borrow/look at/contribute to. If not, I will look at converting a
> little more of RSPerl tomorrow to see if I can get something actually
> useful working.
>
> Alex Gutteridge

Have you thought about simply spawning an inferior process and simply
pass R scripts into the process?  This is basically what emacs does
with their ESS mode and it works wonderfully well.  Depending on the
level of integration that you wanted to achieve between R and Ruby this
could work very well.  I'm not sure how well suited the R system is to
be treated as a library, though I'll confess I haven't really looked
into it.

If one were to simply use an inferior process that you passed straight
R scripts into you could write a set of functions to translate between
Ruby and R speak (array notation, using <- instead of =, parsing
through the response from R to set a global hash of R variables, etc).

I'd be willing to contribute and test stuff as I use R quite a bit for
data analysis.  Its a very, very good language for doing mathematics,
statistics, and modelling that I don't want to redo in Ruby.  Not that
I couldn't I just don't want to repeat the effort.  The biggest problem
is R has a huge lack of string processing features that make setting up
model runs and generating reports that Ruby is quite good at.