RSRuby のインストール

2006-04-05 に Alex さんが RSRuby の公開をはじめました.まだまだα版なので絶賛バグ出し中といった状態です.

RSRuby/README を参考にして,Mac OS X にインストールしてみました.

環境

% uname -a
Darwin meta.local 8.6.0 Darwin Kernel Version 8.6.0: Tue Mar  7 16:58:48 PST 2006; root:xnu-792.6.70.obj~1/RELEASE_PPC Power Macintosh powerpc
% R --version
R 2.2.1 (2005-12-20).
Copyright (C) 2005 R Development Core Team

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the GNU
General Public License.  For more information about these matters,
see http://www.gnu.org/copyleft/gpl.html.

ソフトウェアアップデートで最新まであげた Tiger に R-2.2.1 を dmg からインストールしたものです.

Ruby from R 部分のインストール

% tar zxvf rsruby.tar.gz
% export R_HOME=/Library/Frameworks/R.framework/Resources
% sudo R CMD INSTALL RSRuby
[snip]

R_HOME の設定はこれでいいのか不明です.

R from Ruby 部分のインストール

% cd RSRuby/lib
% /usr/local/bin/ruby extconf.rb --with-R-dir=/Library/Frameworks/R.framework/Versions/2.2/Resources
% make
% /usr/local/bin/ruby  ../test/test_rsruby.rb
Loaded suite ../test/test_rsruby
Started
.Error: couldn't find function "vimto"
Error: couldn't find function "vimto"
.[1] "me"
......Error: couldn't find function "nonsense"
.
Finished in 0.910588 seconds.

9 tests, 20 assertions, 0 failures, 0 errors
% sudo make install

R のパッケージ vimto がインストールされていないのでエラーが出ていますが,RSRuby 自体はテストが問題なく終わっています.

試してみます

% /usr/local/bin/ruby -r rsruby -e 'require "rsruby"; r = RSRuby.new; p r.example("plot"); p r'
% ls Rplots.ps
Rplots.ps
% open Rplots.ps
% irb
irb(main):001:0> require 'rsruby'
=> true
irb(main):002:0> r = RSRuby.new
=> #
irb(main):003:0> r.sum(1,2,3,4,5)
=> 15
irb(main):004:0> r.c(1,2,3,4,5)
=> [1, 2, 3, 4, 5]
irb(main):005:0> r.sum r.c(1,2,3,4,5)
=> 15
irb(main):006:0> r.seq(1, 10, 2)
=> [1, 3, 5, 7, 9]

うごきました.感動した.