- filename = 'R-png_' << rand(10000).to_s unless defined? filename and filename - text = filename unless defined? text and text - size = 500 unless defined? size and size - width = size unless defined? width and width - height = size unless defined? height and height - plot = block.call unless (defined? plot and plot) or not defined? block - filename += '.png' unless filename =~ /\.png$/i - require 'rbbt/util/R' = resource filename, text, :image do |filename| - TmpFile.with_file(plot) do |plot_file| - if defined? data - data.R "rbbt.require('readr'); plot_str <- read_file('#{ plot_file }'); rbbt.png_plot('#{filename}', plot_str, width=#{width}, height=#{height})" - else - R.run "rbbt.require('readr'); plot_str <- read_file('#{ plot_file }'); rbbt.png_plot('#{filename}', plot_str, width=#{width}, height=#{height})"