title: Finding 3 columns with highest value in each row and put their name in a new data frame in R
body: <p>I have the following data frame:</p>
  
  <pre><code>temp1=data.frame(id=c(1,2,3,4,5),p1=c(0,0,1,1,2),p2=c(9,2,3,5,3),p3=c(1,4,10,3,7),p4=c(4,4,7,1,10))
  
    id p1 p2 p3 p4
    1  0  9  1  4
    2  0  2  3  4
    3  1  3 10  7
    4  1  5  3  1
    5  2  3  7 10
  </code></pre>
  
  <p>for each id  I want to extract top three columns with highest value and put them in a new data frame something like this:</p>
  
  <pre><code>id top1 top2 top3
   1  p2   p4   p3
   2  p4   p3   p2
   3  p3   p4   p2
   4  p2   p3   p4/p1
   5  p4   p3   p2
  </code></pre>
  
  <p>in case there are two identical value we are allowed to put them in arbitrary order.</p>