title: Subset data frame in order to contain max value of each row and the column name
body: <p>I want to subset a dataframe (df), in order to contain only the maximum value of each row for columns 1 to 10 and the name of the column.</p>
  
  <p>example dataframe:</p>
  
  <pre><code>    0       1       2       3       4
      0.01    0.12    0.41    0.11    0.11
      0.13    0.12    0.33    0.14    0.07
      0.02    0.20    0.11    0.27    0.17
      0.11    0.33    0.04    0.09    0.24
      0.08    0.07    0.04    0.05    0.58
  </code></pre>
  
  <p>Currently I'm using this:</p>
  
  <pre><code>new_df[] &lt;- apply(df[, 1:4], 1, max) #get the max value of current row
  new_df&lt;- subset(new_df, select = c(1)) #keep only one column
  </code></pre>
  
  <p>I get this:</p>
  
  <pre><code>0.41    
  0.33
  0.27
  0.33
  0.58
  </code></pre>
  
  <p>but I cant get the column name where the max value came from. </p>
  
  <p>Desired result:</p>
  
  <pre><code>    2   0.41    
      2   0.33
      3   0.27
      1   0.33
      4   0.58
  </code></pre>
  
  <p>Thanks in advance for your help.</p>