I like to create separate word clouds for each of my 8 topics in an LDA model. I extracted top 40 words across 8 topics – an object of length 320 containing top words and occurrence probabilities.
I am struggling with accessing the terms and probabilities from my top_words_vector object. It is hard to reproduce bc of the tmResult object, but any hint would be much appreciated:
top_words_vector = c() # a container of length 8x40 = 320 for top40 terms across 8 topics
for(i in 1:8){
top_words_vector=c(top_words_vector,sort(tmResult$terms[i,], decreasing=TRUE)[1:40])
}
wordcloud() takes terms and probs separately, that’s what I am trying to extract from top_words_vector:
mycolors <- brewer.pal(8, "Dark2")
wordcloud(c("apple", "banana"), c(0.8,0.2), random.order = TRUE, color = mycolors)