Sha256: 7368cac93f7167be9289273352ac6865ce711d1334d00c663848352f8f81f12d
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
#!/usr/bin/ruby $:.unshift(File.dirname(__FILE__)+'/../lib/') # == Description # # This example demonstrates creation of basic Vectors and DataFrames. require 'statsample' Statsample::Analysis.store(Daru::DataFrame) do # We set lazy_update to *true* so that time is not wasted in updating # metdata every time an assignment happens. Daru.lazy_update = true samples = 1000 # The 'new_with_size' function lets you specify the size of the # vector as the argument and the block specifies how each element # of the vector will be created. a = Daru::Vector.new_with_size(samples) {r=rand(5); r==4 ? nil: r} b = Daru::Vector.new_with_size(samples) {r=rand(5); r==4 ? nil: r} # Pass the Daru::Vector objects in a Hash to the DataFrame constructor # to make a DataFrame. # # The *order* option lets you specify the way the vectors in the Hash # will be ordered. Not specifyin this will order vectors in alphabetical # order by default. ds = Daru::DataFrame.new({:a=>a,:b=>b}, order: [:b, :a]) summary(ds) # Reset lazy_update to *false* to prevent other code from breaking. Daru.lazy_update = false end if __FILE__==$0 Statsample::Analysis.run_batch end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
statsample-2.0.2 | examples/dataset.rb |
statsample-2.0.1 | examples/dataset.rb |
statsample-2.0.0 | examples/dataset.rb |