lib/statsample/crosstab.rb in statsample-0.3.2 vs lib/statsample/crosstab.rb in statsample-0.3.3
- old
+ new
@@ -2,10 +2,12 @@
# Class to create crosstab of data
# With this, you can create reports and do chi square test
# The first vector will be at rows and the second will the the columns
#
class Crosstab
+ include GetText
+ bindtextdomain("statsample")
attr_reader :v_rows, :v_cols
attr_accessor :row_label, :column_label
def initialize(v1,v2)
raise ArgumentError, "Both arguments should be Vectors" unless v1.instance_of? Vector and v2.instance_of? Vector
raise ArgumentError, "Vectors should be the same size" unless v1.size==v2.size
@@ -86,14 +88,14 @@
rn=rows_names
cn=cols_names
total=0
total_cols=cn.inject({}) {|a,x| a[x]=0;a}
out.add "Chi Square: #{chi_square}\n"
- out.add "Rows: #{@row_label}\n" unless @row_label.nil?
- out.add "Columns: #{@column_label}\n" unless @column_label.nil?
+ out.add(_("Rows: %s\n") % @row_label) unless @row_label.nil?
+ out.add(_("Columns: %s\n") % @column_label) unless @column_label.nil?
- t=Statsample::ReportTable.new([""]+cols_names+["Total"])
+ t=Statsample::ReportTable.new([""]+cols_names+[_("Total")])
rn.each{|row|
total_row=0
t_row=[@v_rows.labeling(row)]
cn.each{|col|
data=fq[[row,col]]
@@ -104,10 +106,10 @@
}
t_row.push(total_row)
t.add_row(t_row)
}
t.add_horizontal_line
- t_row=["Total"]
+ t_row=[_("Total")]
cn.each{|v|
t_row.push(total_cols[v])
}
t_row.push(total)
t.add_row(t_row)