title: How do I generate the top words by tf-idf for each document in R?
body: <p>I've got a document-term matrix from the <code>tm</code> package in R.</p>
  
  <pre><code>dd &lt;- Corpus(VectorSource(train$text)) #Make a corpus object from a text vector
  #Clean the text
  dd &lt;- tm_map(dd, stripWhitespace)
  dd &lt;- tm_map(dd, tolower)
  dd &lt;- tm_map(dd, removePunctuation)
  dd &lt;- tm_map(dd, removeWords, stopwords("english"))
  dd &lt;- tm_map(dd, stemDocument)
  dd &lt;- tm_map(dd, removeNumbers)
  dtm &lt;- DocumentTermMatrix(dd, control = list(weighting = weightTfIdf))
  </code></pre>
  
  <p>I can't find a way to operate on the Document Term Matrix to extract the information I want: the top three keywords by tf-idf for each document. How do I get that?</p>
  
  <p>EDIT:
  Example text (all from the Yelp Review Academic Data Set):</p>
  
  <pre><code>doc1 &lt;- "Luckily, I didn't have to travel far to make my connecting flight. And for this, I thank you, Phoenix.  My brief layover was pleasant as the employees were kind and the flight was on time.  Hopefully, next time I can grace Phoenix with my presence for a little while longer."
  doc2 &lt;- "Nobuo shows his unique talents with everything on the menu. Carefully crafted features with much to drink. Start with the pork belly buns and a stout. Then go on until you can no longer."
  doc3 &lt;- "The oldish man who owns the store is as sweet as can be. Perhaps sweeter than the cookies or ice cream. Here's the lowdown: Giant ice cream cookie sandwiches for super cheap. The flavor permutations are basically endless. I had snickerdoodle with cookies and cream ice cream. It was marvelous."
  </code></pre>
  
  <p>I should mention that I have over 180,000 documents of this nature, so a solution that scales, rather than one that works solely on these specific examples, would be great.</p>