module DataBlockToR
Public Class Methods
create_function( blk )
click to toggle source
# File lib/statsailr/block_to_r/sts_block_to_r.rb, line 48 def self.create_function( blk ) load_datasailr_library() out_ds = blk.out if set_ds = blk.opts["set"] else raise "DATA block requires set= option for input dataset" end puts "Processing data [input:#{set_ds.to_s} ouput:#{out_ds.to_s}]" ds_script = blk.script datasailr_func = RBridge.create_function_call( "sail" , {"df" => set_ds.to_r_symbol, "code" => RBridge.create_strvec([ds_script])} ) r_func = RBridge.create_assign_function( out_ds.to_s , datasailr_func ) end
load_datasailr_library()
click to toggle source
# File lib/statsailr/block_to_r/sts_block_to_r.rb, line 31 def self.load_datasailr_library if ! @datasailr_library_loaded begin lib_func1 = RBridge.create_library_function("datasailr") result = RBridge.exec_function(lib_func1) @datasailr_library_loaded = true rescue => err puts "ERROR: 'datasailr' package cannot be found in the following R library paths." libpath = RBridge.create_function_call(".libPaths", {}) RBridge.exec_function_no_return( RBridge.create_function_call("print", {"x" => libpath})) puts "Please make sure that the package is installed in one of the libraries." err.set_backtrace([]) raise err, "DATA block evaluation failed" end end end