http://www.u.arizona.edu/~ryckman/Documents/RTutorial.pdf
http://rubyforge.org/projects/rsruby/
http://github.com/alexgutteridge/rsruby/tree/master
https://github.com/alexgutteridge/rsruby
http://web.kuicr.kyoto-u.ac.jp/~alexg/rsruby/manual.pdf
<code>
# rerun this command whenever R.app is updated.
$ sudo gem install rsruby -- --with-R-dir=$R_HOME
== Installation A working R installation is required. R must have been built with the '--enable-R-shlib' option enabled to provide the R shared library used by RSRuby. Ensure the R_HOME environment variable is set appropriately. E.g.: R_HOME=/usr/lib/R (on Ubuntu Linux) R_HOME=/Library/Frameworks/R.framework/Resources (on OS X) An RSRuby gem is available as well as a package using setup.rb. In each case the installation requires the location of your R library to compile the extension. This is usually the same as R_HOME. If you download the setup.rb package use these incantations: ruby setup.rb config -- --with-R-dir=$R_HOME ruby setup.rb setup ruby setup.rb install Using gems it is almost the same: gem install rsruby -- --with-R-dir=$R_HOME If RSRuby does not compile correctly you may need to configure the path to the R library, any one of the following should be sufficient: o Put the following line in your .bashrc (or equivalent): export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:RHOME/bin o or, make a link to RHOME/bin/libR.so in /usr/local/lib or /usr/lib, then run 'ldconfig'. o or, edit the file /etc/ld.so.conf, add the following line and then run 'ldconfig': RHOME/bin
~ $ irb
>> require 'rsruby'
=> true
>> r = RSRuby.instance
=> #<RSRuby:0x1011fbab0 @caching=true, @cache={"get"=>#<RObj:0x1011fb718>, "helpfun"=>#<RObj:0x1011f8400>, "help"=>#<RObj:0x1011f8400>, "NaN"=>NaN, "FALSE"=>false, "TRUE"=>true, "F"=>false, "NA"=>-2147483648, "eval"=>#<RObj:0x1011f9918>, "T"=>true, "parse"=>#<RObj:0x1011f9d00>}, @proc_table={}, @class_table={}, @default_mode=-1>
>> cc = []
=> []
>> cc << 1
=> [1]
>> cc << 45
=> [1, 45]
>> cc << 23
=> [1, 45, 23]
>> cc << 4
=> [1, 45, 23, 4]
>> cc
=> [1, 45, 23, 4]
>> r.sum(cc)
=> 73
>> r.max(cc)
=> 45
>> r.sort(cc)
=> [1, 4, 23, 45]
>> cc.sort
=> [1, 4, 23, 45]
>> r.length(cc)
=> 4
</code>
No comments:
Post a Comment