title: Select a column by criteria *and* the column name in each row of an R dataframe?
body: <p>If I have a dataframe of election results by district and candidate, is there an easy way to find the winner in each district in R? That is, for each row, select both the maximum value <em>and</em> the column name for that maximum value?</p>
  
  <pre><code>District   CandidateA   CandidateB   CandidateC
  1          702          467          35
  2          523          642          12
  ...
  </code></pre>
  
  <p>So I'd want to select not only 702 in row 1 and 642 in row 2, but also "CandidateA" from row 1 and "CandidateB" in row 2. </p>
  
  <p>I'm asking this as a learning question, as I know I can do this with any general-purpose scripting language like Perl or Ruby. Perhaps R isn't the tool for this, but it seems like it could be. Thank you.</p>