title: Selecting d3 data subset based on column
body: <p>How do I adapt the code below from <a href="http://bl.ocks.org/mbostock/3884955" rel="noreferrer">http://bl.ocks.org/mbostock/3884955</a> to select specific columns?</p>
  
  <pre><code>var line = d3.svg.line()
  .x(function(d) { return x(d.date); })
  .y(function(d) { return y(d.temperature); });
  
  d3.tsv("data.tsv", function(error, data) {
    color.domain(d3.keys(data[0]).filter(function(key) { return key !== "date"; }));
  
    data.forEach(function(d) {
      d.date = parseDate(d.date);
    });
  
    var cities = color.domain().map(function(name) {
      return {
        name: name,
        values: data.map(function(d) {
          return {date: d.date, temperature: +d[name]};
        })
      };  
  
    });
  </code></pre>
  
  <p>In the data being used in the example above, there are 4 columns: dates and 3 columns for temperature in 3 cities. In my use case, i have 10 columns: dates and 3 variables per city for 3 cities i.e. (1 + [3 * 3]). I would like to load the entire data set (for use in tooltips), but only want to chart one of the variables per city which is in column index # 1, 4 and 7. How do I do this? (see rough syntax below).</p>
  
  <pre><code>var cities = color.domain().map(function(name) {
    return {
      name: name,
      values: data.map(function(d) {
        return {date: d.date, maxTemperature: *+d[arrays in column index 1, 4 and 7]*};
      })
      values2: data.map(function(d) {
        return {date: d.date, minTemperature: *+d[arrays in column index 2, 5 and 8]*};
      })
      values3: data.map(function(d) {
        return {date: d.date, avgTemperature: *+d[arrays in column index 3, 8 and 9]*};
      })
    };
  });
  </code></pre>