Sha256: 2e146a82b0776a9d27c70bcc4c4c7f9bc2181bfa5322c8ebd513ef9db1df710e

Contents?: true

Size: 867 Bytes

Versions: 18

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 DBD 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

18 entries across 18 versions & 1 rubygems

Version Path
rbbt-util-5.9.8 share/rbbt_commands/stat/density
rbbt-util-5.9.7 share/rbbt_commands/stat/density
rbbt-util-5.9.6 share/rbbt_commands/stat/density
rbbt-util-5.9.5 share/rbbt_commands/stat/density
rbbt-util-5.9.4 share/rbbt_commands/stat/density
rbbt-util-5.9.3 share/rbbt_commands/stat/density
rbbt-util-5.9.2 share/rbbt_commands/stat/density
rbbt-util-5.9.1 share/rbbt_commands/stat/density
rbbt-util-5.9.0 share/rbbt_commands/stat/density
rbbt-util-5.8.10 share/rbbt_commands/stat/density
rbbt-util-5.8.9 share/rbbt_commands/stat/density
rbbt-util-5.8.8 share/rbbt_commands/stat/density
rbbt-util-5.8.7 share/rbbt_commands/stat/density
rbbt-util-5.8.6 share/rbbt_commands/stat/density
rbbt-util-5.8.4 share/rbbt_commands/stat/density
rbbt-util-5.8.3 share/rbbt_commands/stat/density
rbbt-util-5.8.2 share/rbbt_commands/stat/density
rbbt-util-5.8.1 share/rbbt_commands/stat/density