title: How to look up field name from an aggregate result
body: <p>I am trying to look up the index or name of a data frame based on the maximum of the aggrate values of that data frame, for example:</p>
  
  <pre><code>df &lt;- data.frame(
          id = 1:6, 
          v1 = c(3, 20, 34, 23, 23, 56),
          v2 = c(1, 3, 4, 10, 30, 40),
          v3 = c(20, 35, 60, 60, 70, 80))
  
    id v1 v2 v3  
  1  1  3  1 20  
  2  2 20  3 35  
  3  3 34  4 60  
  4  4 23 10 60  
  5  5 23 30 70  
  6  6 56 40 80  
  
  &gt; colSums(as.data.frame(df[[1]]))  
  df[[1]]  
       21   
  
  &gt; colSums(as.data.frame(df[[2]]))  
  df[[2]]   
      159   
  
  &gt; colSums(as.data.frame(df[[3]]))  
  df[[3]]   
       88  
  </code></pre>
  
  <p>So for example the maximum result using <code>colSums</code> is 159, and I'm trying to figure out how to to return '<code>df[[2]]</code>'</p>