Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #Bla bla bla z jej kodu
  2.  
  3. docs <- tm_map(docs, stemDocument)
  4. # Build a table containing the frequency of the words:
  5. dtm <- TermDocumentMatrix(docs)
  6. m <- as.matrix(dtm)
  7. v <- sort(rowSums(m),decreasing=TRUE)
  8. d <- data.frame(word = names(v),freq=v)
  9. head(d, 10) # specify how many words you want to have in your table, in this case we have 10.
  10. # Generate the word cloud
  11. set.seed(1234)
  12. wordcloud(words = d$word, freq = d$freq, min.freq = 2, # specify the minimum frequency for each word
  13. max.words=250, random.order=FALSE, rot.per=0.35, # specify the maximum number of words in your cloud
  14. colors=brewer.pal(8, "Set2")) # select the color pallet
  15. # You can also prepare a list of words that occurs at least give number of times:
  16. findFreqTerms(dtm, lowfreq = 10)
  17. # You can find the list of words that are associated with the one of your choice, with the lowest specified correlation value
  18. findAssocs(dtm, terms = "research", corlimit = 0.6)
  19. # You can also plot a bar chart with frequencies of the most popular words in your text:
  20. barplot(d[1:10,]$freq, las = 2, names.arg = d[1:10,]$word,
  21. col ="violet", main ="Most frequent words",
  22. ylab = "Word frequencies")
  23. # The end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement