lib/rbbt/util/R.rb in rbbt-util-5.17.0 vs lib/rbbt/util/R.rb in rbbt-util-5.17.1

- old
+ new

@@ -6,15 +6,22 @@ LIB_DIR = Path.setup(File.join(File.expand_path(File.dirname(__FILE__)),'../../../share/Rlib')) UTIL = File.join(LIB_DIR, 'util.R') PLOT = File.join(LIB_DIR, 'plot.R') - def self.run(command, options = {}) + def self.run(command, source = nil, options = {}) cmd =<<-EOF # Loading basic rbbt environment source('#{UTIL}'); EOF + + require_sources = source.collect{|source| + source = R::LIB_DIR["plot.R"] if source == :plot + "source('#{source}')" + } * ";\n" if Array === source and source.any? + + cmd << require_sources + "\n\n" if require_sources case when IO === command cmd << command.read when File.exists?(command)