如何用 R 建立黑白詞雲?
根據 Google 的說法,詞雲是一種由特定文字或主題中使用的單片語成的影像,其中每個單詞的大小表示其頻率或重要性。在 R 中,我們可以使用 wordcloud 軟體包的 wordcloud 函式建立詞雲。因此,我們具有與該軟體包相同的函式名,因此我們不應該因此感到困惑。
載入 wordcloud 軟體包並建立詞雲 −
library("wordcloud")
x<-c("tutorialspoint is one of the best free resources for online learning")
wordcloud(x)警告資訊 −
- 在 tm_map.SimpleCorpus(corpus, tm::removePunctuation) 中 −
變換會刪除文件
- 在 tm_map.SimpleCorpus(corpus, function(x) tm::removeWords(x, tm::stopwords())) 中 −
變換會刪除文件
輸出

讓我們來看另一個示例 −
y<-c("covid-19 has changed almost everything that happens around the world")
wordcloud(y)警告資訊 −
- 在 tm_map.SimpleCorpus(corpus, tm::removePunctuation) 中 −
變換會刪除文件
- 在 tm_map.SimpleCorpus(corpus, function(x) tm::removeWords(x, tm::stopwords())) 中 −
變換會刪除文件
輸出

廣告
資料結構
網路連線
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP