Skip to content

Instantly share code, notes, and snippets.

@bmarini
Created April 15, 2010 18:33
Show Gist options
  • Save bmarini/367469 to your computer and use it in GitHub Desktop.
Save bmarini/367469 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'ruport'
t = Table(%w[date vert a b])
t << ["2010-01-01", "life",10,20]
t << ["2010-01-01", "life",10,20]
t << ["2010-01-02", "life",10,20]
t << ["2010-01-03", "life",10,20]
t << ["2010-01-04", "life",10,20]
t << ["2010-01-01", "health",10,20]
t << ["2010-01-02", "health",10,20]
t << ["2010-01-03", "health",10,20]
t << ["2010-01-04", "health",10,20]
t.add_column('date-vert') { |r| [r.date, r.vert].join('-') }
g = Grouping(t,:by => ['date-vert'])
s = g.summary('date-vert',
:a => lambda { |r| r.sum('a') },
:b => lambda { |r| r.sum('b') }
)
puts s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment