Module: R

Defined in:
lib/rbbt/util/R.rb

Constant Summary collapse

LIB_DIR =
File.join(File.expand_path(File.dirname(__FILE__)),'../../../share/lib/R')
UTIL =
File.join(LIB_DIR, 'util.R')

Class Method Summary collapse

Class Method Details

.run(command, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rbbt/util/R.rb', line 9

def self.run(command, options = {})
  cmd = "source('#{UTIL}');\n"
  case
  when IO === command
    cmd << command.read
  when File.exists?(command)
    cmd << File.open(command, 'r') do |f| f.read end
  else
    cmd << command
  end

  Log.debug "R Script:\n#{ cmd }"

  CMD.cmd('R --vanilla --slave --quiet', options.merge(:in => cmd))
end