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