Skip to content

Instantly share code, notes, and snippets.

@timrandg
Created January 22, 2012 06:39
Show Gist options
  • Save timrandg/1655958 to your computer and use it in GitHub Desktop.
Save timrandg/1655958 to your computer and use it in GitHub Desktop.
require 'rinruby'
def point_plot(data_dir, data_file, pdf_file)
data_in = File.join(data_dir, data_file)
pdf = File.join(data_dir, pdf_file)
r = RinRuby.new(:echo=>false)
puts "Messages From R console:"
r.eval <<EOF
pdf(#{pdf.inspect}, onefile = TRUE)
library('ggplot2')
data <-read.table(#{data_in.inspect})
qplot(row(data), data$V1,geom=c('point', 'path'))
dev.off()
EOF
puts "Opening #{pdf}"
system("open #{pdf}")
end
data_dir = '/Users/Tim/Library/Containers/com.apple.TextEdit/Data/Desktop/NXT_Data'
data_file = 'DLog.txt'
pdf_file = 'out_file.pdf'
point_plot(data_dir, data_file, pdf_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment