title: LDA with topicmodels, how can I see which topics different documents belong to?
body: <p>I am using LDA from the topicmodels package, and I have run it on about 30.000 documents, acquired 30 topics, and got the top 10 words for the topics, they look very good. But I would like to see which documents belong to which topic with the highest probability, how can I do that?</p>
  
  <pre><code>myCorpus &lt;- Corpus(VectorSource(userbios$bio))
  docs &lt;- userbios$twitter_id
  myCorpus &lt;- tm_map(myCorpus, tolower)
  myCorpus &lt;- tm_map(myCorpus, removePunctuation)
  myCorpus &lt;- tm_map(myCorpus, removeNumbers)
  removeURL &lt;- function(x) gsub("http[[:alnum:]]*", "", x)
  myCorpus &lt;- tm_map(myCorpus, removeURL)
  myStopwords &lt;- c("twitter", "tweets", "tweet", "tweeting", "account")
  
  # remove stopwords from corpus
  myCorpus &lt;- tm_map(myCorpus, removeWords, stopwords('english'))
  myCorpus &lt;- tm_map(myCorpus, removeWords, myStopwords)
  
  
  # stem words
  # require(rJava) # needed for stemming function 
  # library(Snowball) # also needed for stemming function 
  # a &lt;- tm_map(myCorpus, stemDocument, language = "english")
  
  myDtm &lt;- DocumentTermMatrix(myCorpus, control = list(wordLengths=c(2,Inf), weighting=weightTf))
  myDtm2 &lt;- removeSparseTerms(myDtm, sparse=0.85)
  dtm &lt;- myDtm2
  
  library(topicmodels)
  
  rowTotals &lt;- apply(dtm, 1, sum)
  dtm2 &lt;- dtm[rowTotals&gt;0]
  dim(dtm2)
  dtm_LDA &lt;- LDA(dtm2, 30)
  </code></pre>