# Calling R from Ruby

**URL:** <https://rubytalk.org/t/calling-r-from-ruby/26219>\
**Category:** ruby-talk\
**Created:** [29 March 2006 09:08 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219 "2006-03-29T09:08:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexG](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@AlexG](https://rubytalk.org/u/AlexG)\
**Post date:** [29 March 2006 09:08 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/1 "2006-03-29T09:08:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Wilson\_Bilkovich](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/wilson_bilkovich/32/8247_2.png) [@Wilson\_Bilkovich](https://rubytalk.org/u/Wilson_Bilkovich)\
**Post date:** [29 March 2006 14:26 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/2 "2006-03-29T14:26:20Z")

</div>

How about this?  
[http://rubyforge.org/projects/r4ruby/](http://rubyforge.org/projects/r4ruby/)  
I haven't used it myself, but from the description, it sounds like  
what you're looking for.

> **···**
>
> On 3/29/06, AlexG \<alexg@ebi.ac.uk\> 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.

---

<div class="post-metadata">

**Author:** ![gordon.j.miller](https://avatars.discourse-cdn.com/v4/letter/g/a698b9/32.png) [@gordon.j.miller](https://rubytalk.org/u/gordon.j.miller)\
**Post date:** [29 March 2006 15:38 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/3 "2006-03-29T15:38:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Interfecus](https://avatars.discourse-cdn.com/v4/letter/i/d78d45/32.png) [@Interfecus](https://rubytalk.org/u/Interfecus)\
**Post date:** [29 March 2006 23:08 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/4 "2006-03-29T23:08:42Z")

</div>

May I ask what this is for? I've had to learn R recently after working  
with Ruby for a while and find myself thinking constantly "This would  
be much simpler if I could only use Ruby!". As far as I've worked out  
so far:

R's advantages:  
Fast matrix library.  
Inbuilt graphing.  
Don't have to teach statisticians OO concepts.  
Specialised.

R's disadvantages:  
Procedural, with highly limited function support.  
Slow loops.  
Depends on blas (and as a result libfortran).  
Specialised.

For most purposes, you could do better using Ruby with a good graphing  
system (such as gnuplot). There are, of course exceptions, but I would  
consider all options first.

---

<div class="post-metadata">

**Author:** ![AlexG](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@AlexG](https://rubytalk.org/u/AlexG)\
**Post date:** [5 April 2006 07:13 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/5 "2006-04-05T07:13:47Z")

</div>

Hi,

There is a version of my R embedding code at:

[http://web.kuicr.kyoto-u.ac.jp/~alexg/files](http://web.kuicr.kyoto-u.ac.jp/~alexg/files)

This is very very rough and early. Think pre-pre-alpha. It is a  
conversion of the core part of RSPerl allowing you to call R functions  
from ruby scripts and pass simple data between them. Simple data means:  
integers, floats and strings and arrays and hashes thereof. So you can  
write:

require 'rsruby'  
r=RSRuby.new #initialize embedded R interpreter  
samples = 100  
normal = r.rnorm(samples) #Calls R function 'rnorm'  
puts normal #a Ruby array of floats converted from R vector  
r.plot({ 'x' =\> normal, #You can call with named args  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'xlab' =\> 'Hello Ruby',  
&nbsp;&nbsp;&nbsp;'ylab' =\> 'Ruby ga suki desu'})  
sleep(4) #Ooooh - pretty!

At this level it doesn't provide anything that Gordon/Ed's suggestion  
of using an external R interpreter couldn't do. But perhaps with a bit  
more work it might.

Anyway, if you're interested feel free to download and test. I've tried  
it on a linux box and OSX, I have no idea how to build it under Windows  
(or even if you could!). Documentation is essentially non-existent at  
this stage, though there's a README which tells you how to build - you  
just need to tell extconf.rb where your libR sits.

You can find my email address for bug reports/contributions in the  
DESCRIPTION file.

Cheers,

AlexG

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [29 March 2006 23:20 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/6 "2006-03-29T23:20:59Z")

</div>

> May I ask what this is for? I've had to learn R recently after working  
> with Ruby for a while and find myself thinking constantly "This would  
> be much simpler if I could only use Ruby!". As far as I've worked out  
> so far:
> 
> R's advantages:  
> Don't have to teach statisticians OO concepts.  
> Specialised.

you really can subtract

> Fast matrix library.  
> Inbuilt graphing.

because narray and gnuplot are very good. narray is \_\_very\_\_ fast.

regards.

-a

> **···**
>
> On Thu, 30 Mar 2006, Timothy Goddard wrote:  
> --  
> share your knowledge. it's a way to achieve immortality.  
> - h.h. the 14th dali lama

---

<div class="post-metadata">

**Author:** ![AlexG](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@AlexG](https://rubytalk.org/u/AlexG)\
**Post date:** [30 March 2006 00:53 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/7 "2006-03-30T00:53:42Z")

</div>

Yeah, from the description it is exactly what I was thinking of.  
Unfortunately there's no code to download and the last message on  
either the rubyforge site or the wiki is from February 2005 - saying  
that something would get released in July 2005. Sadly it looks like a  
dead project, which kind of implies the whole idea is harder than I  
first imagined. Thanks anyway.

---

<div class="post-metadata">

**Author:** ![AlexG](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@AlexG](https://rubytalk.org/u/AlexG)\
**Post date:** [30 March 2006 01:23 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/8 "2006-03-30T01:23:42Z")

</div>

Timothy Goddard wrote:

> May I ask what this is for? I've had to learn R recently after working  
> with Ruby for a while and find myself thinking constantly "This would  
> be much simpler if I could only use Ruby!".

Like you, I spend most of my time in R wishing I could use Ruby.  
However, whatever I'm doing, I always seem find a few R  
functions/libraries that are really useful. I could rewrite the  
functions in Ruby, but by then I'd have found some more functions that  
I needed and so on. A universal .evalR function that I could call from  
Ruby would make all that pain go away. The inbulit graphing is also  
nice, though as Ara (and yourself) say, gnuplot could replace that  
fairly easily.

For me specifically the ability to use some of the code/classes in the  
Bioconductor project ([http://www.bioconductor.org/\](http://www.bioconductor.org/%5C)) would really be  
nice as well - though I don't know how practical that is.

> For most purposes, you could do better using Ruby with a good graphing  
> system (such as gnuplot). There are, of course exceptions, but I would  
> consider all options first.

Sound advice. I will have a look at trying to get a Ruby-R bridge  
working, but perhaps moving everything to Ruby is the simpler option. I  
will ponder on this further.

AlexG

---

<div class="post-metadata">

**Author:** ![M\_Edward\_Ed\_Borasky1](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@M\_Edward\_Ed\_Borasky1](https://rubytalk.org/u/M_Edward_Ed_Borasky1)\
**Post date:** [30 March 2006 05:18 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/9 "2006-03-30T05:18:56Z")

</div>

> 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.  
> &nbsp;&nbsp;

The "guts" of how to interface R with C, C++ and Fortran, and how to  
build R as a shared library and call it from the "outside world" are  
documented in the "Writing R Extensions" manual that comes with the  
source (or the Windows installer). I took the course up at Fred  
Hutchinson Cancer Research Center in January and we covered this in a  
fair amount of detail. The sample code is on line at

> **[Bioconductor - R for Bioinformatics](https://master.bioconductor.org/help/course-materials/2006/rforbioinformatics/)**
>
> The Bioconductor project aims to develop and share open source software for precise and repeatable analysis of biological data. We foster an inclusive and collaborative community of developers and data scientists.

If you want to do any of this magic on Windows, be prepared to download  
a lot of tools and be prepared to put aside your creative urges and just  
follow directions to the letter. 🙂

I have never used "RSPerl"; I usually call R scripts from Perl via

&nbsp;&nbsp;&nbsp;&nbsp;system("R \< script.R");

passing parameters as environment variables -- Perl exports them and R  
imports them.

> 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).  
> &nbsp;&nbsp;

"=" works in R now as an assignment operator. I'm not sure when that  
happened; I've gotten into the habit of "\<-" and probably don't intend  
to switch. 😉

> 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.  
> &nbsp;&nbsp;

R isn't as bad at "scripting" and "regular expression handling" as all  
that. It ain't Perl and it ain't Ruby, and if you're at all an  
object-oriented programmer, you'll find the way R does objects and  
classes totally different from the "real world". Then again, so is the  
way Perl does it -- Ruby is a lot more like a "real object-oriented  
language."

Of course, when I first started using R, it really sucked at the  
character handling, and I wrote a lot of Perl making "CSV" files for R  
to handle. Nowadays I just load things into a database and let RODBC do  
all the work. 🙂

I'm sorta kinda looking at a project that would use \*Rails\* to manage  
the database(s), shelling out to "R" for the analysis. I've got very  
little lead time, though, so it might have to be just a refactoring of  
the hundreds of lines of Perl and R I have now. And I don't have any  
Ruby-aware cow-orkers ... that's a risk too.

> **···**
>
> gordon.j.miller@gmail.com wrote:
> 
> --  
> M. Edward (Ed) Borasky
> 
> [http://linuxcapacityplanning.com](http://linuxcapacityplanning.com)

---

<div class="post-metadata">

**Author:** ![M\_Edward\_Ed\_Borasky1](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@M\_Edward\_Ed\_Borasky1](https://rubytalk.org/u/M_Edward_Ed_Borasky1)\
**Post date:** [30 March 2006 05:30 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/10 "2006-03-30T05:30:02Z")

</div>

Timothy Goddard wrote:

> May I ask what this is for? I've had to learn R recently after working  
> with Ruby for a while and find myself thinking constantly "This would  
> be much simpler if I could only use Ruby!". As far as I've worked out  
> so far:
> 
> R's advantages:  
> Fast matrix library.  
> Inbuilt graphing.  
> Don't have to teach statisticians OO concepts.  
> Specialised.
> 
> R's disadvantages:  
> Procedural, with highly limited function support.  
> &nbsp;&nbsp;

Au contraire! R is at heart a functional language with a Lisp ancestry!  
What's different about R (and S) is two different ways of doing objects  
and classes, neither one of which is remotely like a Java or Ruby  
programmer's idea of objects and classes.

> Slow loops.  
> &nbsp;&nbsp;

Yeah ... R programmers don't usually use loops -- we use vector and  
matrix operations that have the loops written in C. 🙂 R is probably  
more like APL than it is like Ruby, although it does have some Lisp-like  
and Scheme-like constructs.

> Depends on blas (and as a result libfortran).  
> &nbsp;&nbsp;

Depends on blas for linear algebra only. Can hook up to the  
machine-tuned Atlas linear algebra library if necessary.

> Specialised.  
> &nbsp;&nbsp;

True, R is not a general-purpose environment, although you \*can\* do  
anything in it. If you look at two of its most successful application  
areas, bioinformatics and computational finance, you'll find that the  
"non-numeric" parts of the job aren't \*always\* done outside of the R  
code. That's the way most of us learned to use it, and old habits die  
hard, but I've seen web servers written in R. Check out the "Rpad"  
library for some really nifty things you can do.

> For most purposes, you could do better using Ruby with a good graphing  
> system (such as gnuplot). There are, of course exceptions, but I would  
> consider all options first.  
> &nbsp;&nbsp;

Actually, I think that's been done ... one thing Ruby could use is  
something along the lines of the Perl Data Language/Library. But an "R  
Server" for numerical work would be easy to do.

> **···**
>
> --  
> M. Edward (Ed) Borasky
> 
> [http://linuxcapacityplanning.com](http://linuxcapacityplanning.com)

---

<div class="post-metadata">

**Author:** ![Ptkwt](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Ptkwt](https://rubytalk.org/u/Ptkwt)\
**Post date:** [30 March 2006 05:43 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/11 "2006-03-30T05:43:43Z")

</div>

In article \<1143673625.994253.121460@i40g2000cwc.googlegroups.com\>,

> May I ask what this is for? I've had to learn R recently after working  
> with Ruby for a while and find myself thinking constantly "This would  
> be much simpler if I could only use Ruby!". As far as I've worked out  
> so far:
> 
> R's advantages:  
> Fast matrix library.  
> Inbuilt graphing.  
> Don't have to teach statisticians OO concepts.  
> Specialised.
> 
> R's disadvantages:  
> Procedural, with highly limited function support.  
> Slow loops.  
> Depends on blas (and as a result libfortran).  
> Specialised.
> 
> For most purposes, you could do better using Ruby with a good graphing  
> system (such as gnuplot). There are, of course exceptions, but I would  
> consider all options first.

This has come up before, but maybe we need a Ruby-based DSL that could be aimed  
squarely at the likes of Matlab and R. We'd need to distribute it with a  
graphing system so that it would look like graphing was 'built-in'. We could  
use narray as the basis for fast matrix math. One could stay at the DSL level  
or one could delve more deeply and learn the underlying Ruby in order to get  
the greatest advantage of this sort of math-oriented DSL: users wouldn't have  
to know Ruby, but if they did it would become a more powerful tool. irb could  
be used for an interactive mode...

What should we call this?

rcalc  
rmath  
mathgem  
rubysci  
?

.... a good name can help something like this get started.

Phil

> **···**
>
> Timothy Goddard \<interfecus@gmail.com\> wrote:

---

<div class="post-metadata">

**Author:** ![Ptkwt](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Ptkwt](https://rubytalk.org/u/Ptkwt)\
**Post date:** [30 March 2006 05:43 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/12 "2006-03-30T05:43:43Z")

</div>

In article \<Pine.LNX.4.62.0603291619410.32347@harp.ngdc.noaa.gov\>,

> **···**
>
> \<ara.t.howard@noaa.gov\> wrote:
> 
> > On Thu, 30 Mar 2006, Timothy Goddard wrote:
> > 
> > > May I ask what this is for? I've had to learn R recently after working  
> > > with Ruby for a while and find myself thinking constantly "This would  
> > > be much simpler if I could only use Ruby!". As far as I've worked out  
> > > so far:
> > > 
> > > R's advantages:  
> > > Don't have to teach statisticians OO concepts.  
> > > Specialised.
> > 
> > you really can subtract
> > 
> > > Fast matrix library.  
> > > Inbuilt graphing.
> > 
> > because narray and gnuplot are very good. narray is \_\_very\_\_ fast.
> 
> what are the alternatives to gnuplot? What does R use for it's graphing  
> engine?
> 
> Phil

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [30 March 2006 05:56 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/13 "2006-03-30T05:56:37Z")

</div>

[http://theory.kitp.ucsb.edu/~paxton/tioga\_doc/classes/Tioga/Tutorial/Sample.html](http://theory.kitp.ucsb.edu/~paxton/tioga_doc/classes/Tioga/Tutorial/Sample.html)

i realize it's not totally numerical... but he's thinking along the same  
lines. fyi.

-a

> **···**
>
> On Thu, 30 Mar 2006, Phil Tomson wrote:
> 
> > This has come up before, but maybe we need a Ruby-based DSL that could be aimed  
> > squarely at the likes of Matlab and R. We'd need to distribute it with a  
> > graphing system so that it would look like graphing was 'built-in'. We could  
> > use narray as the basis for fast matrix math. One could stay at the DSL level  
> > or one could delve more deeply and learn the underlying Ruby in order to get  
> > the greatest advantage of this sort of math-oriented DSL: users wouldn't have  
> > to know Ruby, but if they did it would become a more powerful tool. irb could  
> > be used for an interactive mode...
> > 
> > What should we call this?
> > 
> > rcalc  
> > rmath  
> > mathgem  
> > rubysci  
> > ?
> > 
> > .... a good name can help something like this get started.
> 
> --  
> share your knowledge. it's a way to achieve immortality.  
> - h.h. the 14th dali lama

---

<div class="post-metadata">

**Author:** ![M\_Edward\_Ed\_Borasky1](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@M\_Edward\_Ed\_Borasky1](https://rubytalk.org/u/M_Edward_Ed_Borasky1)\
**Post date:** [30 March 2006 06:33 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/14 "2006-03-30T06:33:17Z")

</div>

Phil Tomson wrote:

> This has come up before, but maybe we need a Ruby-based DSL that could be aimed  
> squarely at the likes of Matlab and R.

When you say "we", who are you referring to? People who only know Ruby?  
As far as \*I\* am concerned, R, Axiom and Maxima are (open source) Domain  
Specific Languages for mathematics. Ruby is a general-purpose  
object-oriented language. Sure, Ruby is good for building  
domain-specific languages, but you just aren't going to reinvent all  
those wheels in Ruby.

> We'd need to distribute it with a  
> graphing system so that it would look like graphing was 'built-in'. We could  
> use narray as the basis for fast matrix math. One could stay at the DSL level  
> or one could delve more deeply and learn the underlying Ruby in order to get  
> the greatest advantage of this sort of math-oriented DSL: users wouldn't have  
> to know Ruby, but if they did it would become a more powerful tool. irb could  
> be used for an interactive mode...
> 
> What should we call this?
> 
> rcalc  
> rmath  
> mathgem  
> rubysci  
> ?
> 
> .... a good name can help something like this get started.
> 
> Phil  
> &nbsp;&nbsp;

There are a few things out there, but nothing with as much horsepower as  
R and the two main general purpose symbolic engines, Axiom and Maxima.  
There are hundreds of person-decades involved in building those three  
packages. In fact, the latter two weren't originally open source. Axiom  
was a commercial product, and Maxima was a US government funded project.  
R was always an open source project, however.

> **···**
>
> --  
> M. Edward (Ed) Borasky
> 
> [http://linuxcapacityplanning.com](http://linuxcapacityplanning.com)

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [30 March 2006 05:54 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/15 "2006-03-30T05:54:39Z")

</div>

you can make production quality graphics using

&nbsp;&nbsp;&nbsp;[http://theory.kitp.ucsb.edu/~paxton/tioga.html](http://theory.kitp.ucsb.edu/~paxton/tioga.html)

regards.

-a

> **···**
>
> On Thu, 30 Mar 2006, Phil Tomson wrote:
> 
> > what are the alternatives to gnuplot?
> 
> --  
> share your knowledge. it's a way to achieve immortality.  
> - h.h. the 14th dali lama

---

<div class="post-metadata">

**Author:** ![Ptkwt](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Ptkwt](https://rubytalk.org/u/Ptkwt)\
**Post date:** [30 March 2006 07:03 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/16 "2006-03-30T07:03:42Z")

</div>

In article \<Pine.LNX.4.62.0603292256100.32347@harp.ngdc.noaa.gov\>,

> **···**
>
> \<ara.t.howard@noaa.gov\> wrote:
> 
> > On Thu, 30 Mar 2006, Phil Tomson wrote:
> > 
> > > This has come up before, but maybe we need a Ruby-based DSL that could be aimed  
> > > squarely at the likes of Matlab and R. We'd need to distribute it with a  
> > > graphing system so that it would look like graphing was 'built-in'. We could  
> > > use narray as the basis for fast matrix math. One could stay at the DSL level  
> > > or one could delve more deeply and learn the underlying Ruby in order to get  
> > > the greatest advantage of this sort of math-oriented DSL: users wouldn't have  
> > > to know Ruby, but if they did it would become a more powerful tool. irb could  
> > > be used for an interactive mode...
> > > 
> > > What should we call this?
> > > 
> > > rcalc  
> > > rmath  
> > > mathgem  
> > > rubysci  
> > > ?
> > > 
> > > .... a good name can help something like this get started.
> > 
> > [http://theory.kitp.ucsb.edu/~paxton/tioga\_doc/classes/Tioga/Tutorial/Sample.html](http://theory.kitp.ucsb.edu/~paxton/tioga_doc/classes/Tioga/Tutorial/Sample.html)
> > 
> > i realize it's not totally numerical... but he's thinking along the same  
> > lines. fyi.
> 
> Looks interesting. Hadn't run across it before. Maybe Tioga would be a good  
> candidate for the graphics component of what I'm talking about.
> 
> Phil

---

<div class="post-metadata">

**Author:** ![Ptkwt](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Ptkwt](https://rubytalk.org/u/Ptkwt)\
**Post date:** [30 March 2006 07:28 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/17 "2006-03-30T07:28:42Z")

</div>

In article \<442B7BA3.104@cesmail.net\>,

> Phil Tomson wrote:
> 
> > This has come up before, but maybe we need a Ruby-based DSL that could be aimed  
> > squarely at the likes of Matlab and R.
> 
> When you say "we", who are you referring to? People who only know Ruby?  
> As far as \*I\* am concerned, R, Axiom and Maxima are (open source) Domain  
> Specific Languages for mathematics. Ruby is a general-purpose  
> object-oriented language. Sure, Ruby is good for building  
> domain-specific languages, but you just aren't going to reinvent all  
> those wheels in Ruby.

Where reinvention would take too long, then perhaps it would be best to build  
bridges. I guess in my case I'd like to see something that could take on  
Matlab (a closed source product).

Hey, a couple of years ago we were here in this group discussing how Ruby could  
have an impact in the Web Programming arena since it looked like Ruby was an  
also-ran in that area (there were so many tools that were already dominant in  
that space - or so it seemed). Now Rails has changed all of that. Scientific  
computing/ mathematics is another area where there's room for innovation.

Maybe we take this proposed tool in a slightly different direction. Make  
it easy to make things web-enabled for example, or maybe make it easy to use in  
a cluster environment (taking advantage of drb). A LaTeX equation to  
RubyMathDSL translator. Maybe a Rails, RubyMathDSL, LaTeX mashup where your  
'paper' is some sort of interactive document where you can interact with  
equations and graphs and maybe something that would make it easier to do  
collaborative research where the data in your paper can be referenced by  
other interactive papers which can make use of that data in interesting ways  
and add to it and... Ok, it's getting a bit  
wierd, I'll admit. I'm just trying to spark a bit of brainstorming here...

However that bit about data-sharing between interactive papers seems kind of  
cool. It would give a whole new meaning to a 'bibliography' and 'references'.  
It's not easy right now to share data like that. When I'm reading papers I  
sometimes think "They spent all this time gathering or generating all of this  
wonderful data and putting it into nice little tables or graphs, but there's  
really no way for me to access it". Of course this would require a whole new  
infrastructure for publishing papers as web apps, but this is 2006 afterall.

Phil

> **···**
>
> M. Edward (Ed) Borasky \<znmeb@cesmail.net\> wrote:

---

<div class="post-metadata">

**Author:** ![AlexG](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@AlexG](https://rubytalk.org/u/AlexG)\
**Post date:** [30 March 2006 07:33 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/18 "2006-03-30T07:33:42Z")

</div>

Wow. That's nice. Really nice! Thanks for the link - not seen it  
before.

For those following along at home. I have extended my toy R/Ruby bridge  
to be able to directly call any R function with any number of  
parameters (as long as they're Integers, Floats or Strings!). Or any  
function at all via parse(eval("cmd")). The next step is getting some  
conversion code for arrays, etc... And then a lot of tidying up.

> **···**
>
> On Thurs, Mar 30 2006 2:54 pm Ara wrote:
> 
> > On Thu, 30 Mar 2006, Phil Tomson wrote:  
> > \> what are the alternatives to gnuplot?
> 
> > you can make production quality graphics using
> 
> > &nbsp;&nbsp;[http://theory.kitp.ucsb.edu/~paxton/tioga.html](http://theory.kitp.ucsb.edu/~paxton/tioga.html)

---

<div class="post-metadata">

**Author:** ![Edwin\_Van\_leeuwen](https://avatars.discourse-cdn.com/v4/letter/e/b2d939/32.png) [@Edwin\_Van\_leeuwen](https://rubytalk.org/u/Edwin_Van_leeuwen)\
**Post date:** [30 March 2006 11:06 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/19 "2006-03-30T11:06:57Z")

</div>

unknown wrote:

> Where reinvention would take too long, then perhaps it would be best to  
> build  
> bridges. I guess in my case I'd like to see something that could take  
> on  
> Matlab (a closed source product).

You can already do a lot of what matlab does with ruby-gsl. There are  
also a couple of gnuplot and plotutils bridges to make plotting easy.  
(plotutils bridge is part of ruby-gsl)

For an R bridge I use a simple class that writes stuff to a script file  
and then executes the script with R. It is far from perfect but doable.  
But I would certainly welcome a better bridge.

Edwin

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Thomas5](https://avatars.discourse-cdn.com/v4/letter/t/f4b2a3/32.png) [@Thomas5](https://rubytalk.org/u/Thomas5)\
**Post date:** [30 March 2006 12:20 UTC](https://rubytalk.org/t/calling-r-from-ruby/26219/20 "2006-03-30T12:20:41Z")

</div>

> For an R bridge I use a simple class that writes stuff to a script file and then executes the script with R. It is far from perfect but doable. But I would certainly welcome a better bridge.

If you're on windows, you could quite easily use ole for accessing R.

thomas

[Next page](https://rubytalk.org/t/calling-r-from-ruby/26219.md?page=2)
