美文网首页
Word cloud generation in R

Word cloud generation in R

作者: wkzhang81 | 来源:发表于2023-04-20 11:33 被阅读0次
p_load(tm, SnowballC, wordcloud, RColorBrewer, wordcloud2, tidyverse)
text <- readLines(file.choose())

docs <- Corpus(VectorSource(text))
dtm <- TermDocumentMatrix(docs)
m <- as.matrix(dtm)
v <- sort(rowSums(m),decreasing=TRUE)
d <- data.frame(word = names(v),freq=v)
head(d, 10)
result list
set.seed(123)
wordcloud(words = d$word, freq = d$freq, min.freq = 1,
          max.words=200, random.order=FALSE, rot.per=0.35, 
          colors=brewer.pal(8, "Dark2"))
the wordcloud

相关文章

网友评论

      本文标题:Word cloud generation in R

      本文链接:https://www.haomeiwen.com/subject/uwprjdtx.html