Sha256: 5445d2ca8e286f4bc1d35c922fa1a4da16ed54d60450b534c17df3fc36de29f4

Contents?: true

Size: 867 Bytes

Versions: 73

Compression:

Stored size: 867 Bytes

Contents

#!/usr/bin/env ruby

require 'rbbt'
require 'rbbt/util/simpleopt'

require 'rbbt/util/R'

$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands

options = SOPT.setup <<EOF
Calculate density 

$ rbbt stat density <file>

Display summary information. Works with Tokyocabinet HDB and BDB as well.

-tch--tokyocabinet File is a TC HDB
-tcb--tokyocabinet_bd File is a TC BDB
-h--help Help
EOF

SOPT.usage if options[:help]

file = ARGV.shift

if file == '-' or file.nil?
  file = STDIN 
else
  file = Open.open file
end

values = file.read.split("\n").collect{|v| v.to_f}

res = TmpFile.with_file do |tmp|
  R.run <<-EOF
values = #{R.ruby2R values}
d = density(values)
df = data.frame(x=d$x, y=d$y)
rbbt.tsv.write(file='#{ tmp }', df)
  EOF

  Open.read(tmp)
end

puts res.split("\n")[1..-1].collect{|l| l.split("\t")[1,2] * "\t"} * "\n"

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
rbbt-util-5.14.17 share/rbbt_commands/stat/density
rbbt-util-5.14.16 share/rbbt_commands/stat/density
rbbt-util-5.14.15 share/rbbt_commands/stat/density
rbbt-util-5.14.14 share/rbbt_commands/stat/density
rbbt-util-5.14.12 share/rbbt_commands/stat/density
rbbt-util-5.14.11 share/rbbt_commands/stat/density
rbbt-util-5.14.10 share/rbbt_commands/stat/density
rbbt-util-5.14.9 share/rbbt_commands/stat/density
rbbt-util-5.14.8 share/rbbt_commands/stat/density
rbbt-util-5.14.7 share/rbbt_commands/stat/density
rbbt-util-5.14.6 share/rbbt_commands/stat/density
rbbt-util-5.14.5 share/rbbt_commands/stat/density
rbbt-util-5.14.4 share/rbbt_commands/stat/density
rbbt-util-5.14.3 share/rbbt_commands/stat/density
rbbt-util-5.14.2 share/rbbt_commands/stat/density
rbbt-util-5.14.1 share/rbbt_commands/stat/density
rbbt-util-5.14.0 share/rbbt_commands/stat/density
rbbt-util-5.13.37 share/rbbt_commands/stat/density
rbbt-util-5.13.36 share/rbbt_commands/stat/density
rbbt-util-5.13.35 share/rbbt_commands/stat/density