Method: Statsample::Crosstab#initialize

Defined in:
lib/statsample/crosstab.rb

#initialize(v1, v2, opts = Hash.new) ⇒ Crosstab

Returns a new instance of Crosstab.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/statsample/crosstab.rb', line 10

def initialize(v1, v2, opts=Hash.new)
  raise ArgumentError, "Vectors should be the same size" unless v1.size==v2.size
  @v_rows, @v_cols = Statsample.only_valid_clone(
    Daru::Vector.new(v1),
    Daru::Vector.new(v2))
  @cases          = @v_rows.size
  @row_label      = v1.name
  @column_label   = v2.name
  @name           = nil
  @percentage_row = @percentage_column = @percentage_total=false
  opts.each do |k,v|
    self.send("#{k}=",v) if self.respond_to? k
  end
  @name ||= _("Crosstab %s - %s") % [@row_label, @column_label]
end