title: sort a data frame based on multiple columns in R
body: <p>I execute the following code:</p>
  
  <pre><code>df&lt;-data.frame(word=c("play","win","offer","http"),frequency=c(321,355,123,564),type=c("nonspam","nonspam","spam","spam"))
  
  df=arrange(df,desc(frequency),desc(type))
  
  df=df[order(df[,2],df[,3]),]
  </code></pre>
  
  <p>and the result is:</p>
  
  <pre><code>   word frequency type
  4 offer       123    spam
  3  play       321    nonspam
  2   win       355    nonspam
  1  http       564    spam
  </code></pre>
  
  <p>but I want to sort the data frame with respect to frequency <strong>and</strong> type such as:</p>
  
  <pre><code>word frequency type
      1  http      564    spam
      4  offer     123    spam
      2  win       355    nonspam
      3  play      321    nonspam
  </code></pre>