title: How to extract the row with min or max values?
body: <p>With a dataframe like this one:</p>
  
  <pre><code>        ID  Year    Temp    ph
  1       P1  1996    11.3    6.80
  2       P1  1996    9.7     6.90
  3       P1  1997    9.8     7.10
  ...
  2000    P2  1997    10.5    6.90
  2001    P2  1997    9.9     7.00
  2002    P2  1997    10.0    6.93
  </code></pre>
  
  <p>if I want to know where the max value is I type:</p>
  
  <pre><code>which.max(df$Temp)
  </code></pre>
  
  <p>and R print the index of the row, for example 665.</p>
  
  <p>So, if I want to read and extract the column with all the related values, I have to type:</p>
  
  <pre><code>df[665, ]
  </code></pre>
  
  <p>Isn't there a simpler way to know which ID is related to the max value of a specific column of the df?</p>