crosstab
by Michael Judge mjudge@surveycomplete.com
http://crosstab.rubyforge.org/
== DESCRIPTION:
Crosstab is a library for generating formatted pivot tables.
== FEATURES:
- Input your data as an array of hashes
- Input a report layout, built using a Ruby DSL
- Outputs ASCII pivot tables suitable for fast reports
- Pretty fast: takes less than a second to process 1,000 records of data by a report with 100 rows and 10 columns.
== SYNOPSIS:
require 'rubygems'
require 'crosstab'
data = [{:gender => "M", :age => 1},
{:gender => "F", :age => 2},
{:gender => "M", :age => 3}]
my_crosstab = crosstab data do
table do
title "Q.A Age:"
group "18 - 54" do
row "18 - 34", :age => 1
row "35 - 54", :age => 2
end
row "55 or older", :age => 3
end
banner do
column "Total"
group "Gender" do
column "Male", :gender => "M"
column "Female", :gender => "F"
end
end
end
puts my_crosstab.to_s
=> ...
Table 1
Q.A Age:
Gender
----------------
Total Male Female
(A) (B) (C)
------- ------- -------
(BASE) 3 2 1
18 - 54 2 1 1
----------------------------- 67% 50% 100%
18 - 34 1 1 --
33% 50%
35 - 54 1 -- 1
33% 100%
55 or older 1 1 --
33% 50%
== JUST THE BEGINNING:
- I hope to add in later releases:
- New export formats: html, pdf, csv, excel.
- More stats than just frequency and percentage: mean, median, std. deviation, std. error, and significance testing
- Optional row and table suppression for low frequencies
- Optional table rows populating from the data
- Optional table ranking -- automatically reorder rows based in descending order based on frequencies observed
== REQUIREMENTS:
== INSTALL:
- sudo gem install crosstab
== LICENSE:
(The MIT License)
Copyright (c) 2007 Michael Judge
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.