Can Ruby interface with r?

前端 未结 4 782
感情败类
感情败类 2021-02-19 07:42

A friend needs to do some R programming for her PhD and since I\'m a programmer, asked me to give her a hand.

So I took a look at some r related webstuff and discovered

相关标签:
4条回答
  • 2021-02-19 08:14

    There is also a Ruby client for Rserve.

    0 讨论(0)
  • 2021-02-19 08:15

    See RSRuby for accessing R functionality through Ruby.

    As for a beginner's tutorial, try looking at "R For Beginners". I found it helpful when I had to learn some basic R for a statistics course.

    0 讨论(0)
  • 2021-02-19 08:18

    This presentation summarises the alternatives.

    Libraries

    • RinRuby
    • RSRuby

    Both discussed in others' answers, both haven't been updated years.

    Rserve with Ruby client

    Rserve is a Java TCP/IP server that the native Ruby client can connect to.

    I've just tested out this approach and it's extremely easy.

    sudo apt-get install -y r-base ruby-gems # Just in case...
    
    sudo R
    > install.packages("Rserve")
    > library(Rserve)
    > Rserve()
    
    # (In another window - not sure how the 'daemon mode' operates exactly.
    
    sudo gem install rserve-client
    
    irb
    > require "rserve"
    > include Rserve
    > c = Connection.new
    > x = c.eval("R.version.string");
    > puts x.as_string
    
    R version 2.10.1 (2009-12-14)
      => nil 
    

    rApache and Rook (formerly "rrack")

    rApache is a web application framework for R (just like Rails is for Ruby). I think Rook is a shim to allow rApache to work on non-Apache webservers. So the approach here (I think) is to run rApache and Rails side by side. Your Rails app can call rApache/Rook as needed to perform queries, or to hand over control for rendering graphs etc.

    0 讨论(0)
  • 2021-02-19 08:39

    RinRuby is another project that does the Ruby/R interface.

    0 讨论(0)
提交回复
热议问题