Kevin and Shan’s

Field Guide to Working with Data in the Wild

Grouping

How you aggregate really depends on what you want. Mister Nester is useful for tinkering.

d3.nest()
  .key(function(d) { return d.year; })
  .rollup(function(values) {
    return {
      totalStrikeouts: d3.sum(values, function(d) { return d.strikeouts })
    };
  })
  .entries(data);