szpapas 发表于 2013-1-15 23:45:39

Install R on mac OSX

1. 下载 安装 R
R-2.10.1.pkg
 
 
 
2. 下载安装 git
git-1.6.6.1-intel-leopard.dmg
然后安装
 
 
3. 下载rsruby
git clone git://github.com/alexgutteridge/rsruby.git
设定 R_HOME 变量,在.profile 里面 export 
export  R_HOME=/Library/Frameworks/R.framework/Resources
cd rsruby/
ruby setup.rb config -- --with-R-dir=$R_HOME 
ruby setup.rb setup
sudo ruby setup.rb install
 
4. 验证
 

require 'rsruby'
 
r = RSRuby.instance
 
# construct data to plot, graph of x vs sqrt(x)
xs = 10.times.collect {|i| i}
ys = xs.collect {|x| r.sqrt(x)}
 
r.png("example.png")  # tell R we will create png file
r.plot(:x => xs,
     :y => ys,            # (x,y) coordinates to plot
     :type=> "o",         # draw a line through points
     :col=> "blue",       # colour the line blue
     :main=> "Plot of x against sqrt(x)",  # add title to graph
     :xlab => "x", :ylab => "sqrt(x)")     # add labels to axes
r.eval_R("dev.off()")                        # finish the plotting
 
 

liu-juns-macbook-pro:~ liujun$ irb
 
页: [1]
查看完整版本: Install R on mac OSX