title: Make dataframe of top N frequent terms for multiple corpora using tm package in R
body: <p>I have several <code>TermDocumentMatrix</code>s created with the <code>tm</code> package in R.</p>
  
  <p>I want to find the 10 most frequent terms in each set of documents to ultimately end up with an output table like:</p>
  
  <pre><code>corpus1   corpus2
  "beach"   "city"
  "sand"    "sidewalk"
  ...        ...
  [10th most frequent word]
  </code></pre>
  
  <p>By definition, <code>findFreqTerms(corpus1,N)</code> returns all of the terms which appear N times or more. To do this by hand I could change N until I got 10 or so terms returned, but the output for <code>findFreqTerms</code> is listed alphabetically so unless I picked exactly the right N, I wouldn't actually know which were the top 10. I suspect that this involves manipulating the internal structure of the TDM that you can see with <code>str(corpus1)</code> as in <a href="https://stackoverflow.com/questions/11508728/r-tm-package-create-matrix-of-nmost-frequent-terms">R tm package create matrix of Nmost frequent terms</a> but the answer here was very opaque to me so I wanted to rephrase the question.</p>
  
  <p>Thanks!</p>