title: Extract row corresponding to minimum value of a variable by group
body: <p>I wish to (1) group data by one variable (<code>State</code>), (2) within each group find the row of minimum value of another variable (<code>Employees</code>), and (3) extract the entire row.</p>
  
  <p>(1) and (2) are easy one-liners, and I feel like (3) should be too, but I can't get it.</p>
  
  <p>Here is a sample data set:</p>
  
  <pre><code>&gt; data
    State Company Employees
  1    AK       A        82
  2    AK       B       104
  3    AK       C        37
  4    AK       D        24
  5    RI       E        19
  6    RI       F       118
  7    RI       G        88
  8    RI       H        42
  
  data &lt;- structure(list(State = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 
          2L), .Label = c("AK", "RI"), class = "factor"), Company = structure(1:8, .Label = c("A", 
          "B", "C", "D", "E", "F", "G", "H"), class = "factor"), Employees = c(82L, 
          104L, 37L, 24L, 19L, 118L, 88L, 42L)), .Names = c("State", "Company", 
          "Employees"), class = "data.frame", row.names = c(NA, -8L))
  </code></pre>
  
  <p>Calculate <code>min</code> by group is easy, using <code>aggregate</code>:</p>
  
  <pre><code>&gt; aggregate(Employees ~ State, data, function(x) min(x))
    State Employees
  1    AK        24
  2    RI        19
  </code></pre>
  
  <p>...or <code>data.table</code>:</p>
  
  <pre><code>&gt; library(data.table)
  &gt; DT &lt;- data.table(data)
  &gt; DT[ , list(Employees = min(Employees)), by = State]
     State Employees
  1:    AK        24
  2:    RI        19
  </code></pre>
  
  <p>But how do I extract the entire row corresponding to these <code>min</code> values, i.e. also including <code>Company</code> in the result? </p>