title: Is there an elegant way to reorder data frame by rownames in R
body: <p>I have a dataframe with random row names. And I would like to reorder it by the row names. Say the original dataframe looks like:</p>
  <pre><code>       value
  gene8  0.140533602
  gene6 21.129493396
  gene7  0.170091711
  gene3 28.101415822
  gene1  0.005706749
  gene2  3.157911375
  </code></pre>
  <p>And what I want is:</p>
  <pre><code>       value
  gene1  0.005706749
  gene2  3.157911375
  gene3 28.101415822
  gene6 21.129493396
  gene7  0.170091711
  gene8  0.140533602
  </code></pre>
  <p>After searching for the solution, I've found two ways that can almost solve the issue:</p>
  <ol>
  <li>Using function <code>arrange()</code>. But it can't take row name as the sorting index.</li>
  <li>Using function <code>order()</code> and do it in this way <code>df &lt;- df[order(row.names(df)), ]</code>. But what you get is a numeric vector instead of a dataframe. So the row name will be missing.</li>
  </ol>
  <p>Solution 1 looks very elegant, but it can't achieve my goal. Solution 2 can be used, but some extra work needs to be added (creating a new dataframe assigning the values and row names). Is there a straight-forway way to do the job?</p>