lib/rbbt/util/R.rb in rbbt-util-5.13.6 vs lib/rbbt/util/R.rb in rbbt-util-5.13.7

- old
+ new

@@ -1,7 +1,8 @@ require 'rbbt/util/cmd' require 'rbbt/tsv' +require 'rbbt/util/R/eval' module R LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'../../../share/Rlib') UTIL = File.join(LIB_DIR, 'util.R') @@ -78,25 +79,30 @@ module TSV def R(script, open_options = {}) TmpFile.with_file do |f| Open.write(f, self.to_s) - Log.debug(R.run( + io = R.run( <<-EOF ## Loading tsv into data data = rbbt.tsv('#{f}'); #{script.strip} ## Resaving data if (! is.null(data)){ rbbt.tsv.write('#{f}', data); } EOF - ).read) + ) + + Log.debug(io.read) + open_options = Misc.add_defaults open_options, :type => :list if open_options[:raw] Open.read(f) else - TSV.open(f, open_options) unless open_options[:ignore_output] + tsv = TSV.open(f, open_options) unless open_options[:ignore_output] + tsv.key_field = open_options[:key] if open_options.include? :key + tsv end end end def R_interactive(pre_script = nil)