
Word Cloud (词云) - R
##### >> Related Blogs
1. [Word Cloud (������) - Python](https://www.cnblogs.com/yukiwu/p/10967037.html)2. [Word Cloud (������) - JavaScript](https://www.cnblogs.com/yukiwu/p/10968816.html)3. [Word Cloud (������) - Matlab](https://www.cnblogs.com/yukiwu/p/10971998.html)
发布日期:2021-05-09 09:08:20
浏览次数:17
分类:博客文章
本文共 2593 字,大约阅读时间需要 8 分钟。
��������������������������������������� [Python](https://www.cnblogs.com/yukiwu/p/10967037.html) ��� [JavaScript](https://www.cnblogs.com/yukiwu/p/10968816.html) ������������������������������������ R��������� SPSS ��� SAS ��� Word Cloud ������������������������ R ������������ ##### >> Create Word Cloud via R- ���������������
��������������������������������������� Word Cloud History.txt ���������������������������������������������������������������������������������������������������������������������������������������������
- ������������������������ R ������
# Installinstall.packages("tm") # for text mininginstall.packages("wordcloud") # word-cloud generator install.packages("RColorBrewer") # color palettes# Loadlibrary("tm")library("wordcloud")library("RColorBrewer")
- ���������������������������������������������������������������
inspect()
������������������������������������
#Read text filetext <- readLines(file.choose())# Load the data as a corpusdocs <- Corpus(VectorSource(text))#Inspect the content#inspect(docs)[1:10]
- ������������������������������
tm_map()
������������������������������������������������������������������������������������������
# Convert the text to lower casedocs <- tm_map(docs, content_transformer(tolower))# Remove numbersdocs <- tm_map(docs, removeNumbers)# Remove english common stopwordsdocs <- tm_map(docs, removeWords, stopwords("english"))# Remove punctuationsdocs <- tm_map(docs, removePunctuation)# Eliminate extra white spacesdocs <- tm_map(docs, stripWhitespace)
- ��������������������������������������� (words) ������������ (frequencies) ������������������
TermDocumentMatrix()
��������� text mining ������������������������������������head()
������������������������
#Convert this into a matrix formatm <- as.matrix(dtm)#Gives you the frequencies for every wordv <- sort(rowSums(m),decreasing=TRUE)d <- data.frame(word = names(v),freq=v)#Scan the data#head(d, 10)
- ������ word cloud���
wordcloud(words = d$word, freq = d$freq, scale=c(5,0.5), min.freq = 1, max.words=200, random.order=FALSE, rot.per=0.35, colors=brewer.pal(8, "Accent"))##### >> Notes
��������������� wordcloud()
������������������������������������������������������������������ help(wordcloud)
������ help(RColorBrewer)
���������������������������������
##### >> Related Blogs
1. [Word Cloud (������) - Python](https://www.cnblogs.com/yukiwu/p/10967037.html)2. [Word Cloud (������) - JavaScript](https://www.cnblogs.com/yukiwu/p/10968816.html)3. [Word Cloud (������) - Matlab](https://www.cnblogs.com/yukiwu/p/10971998.html)
发表评论
最新留言
做的很好,不错不错
[***.243.131.199]2025年04月25日 12时50分28秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
解决Vue源码运行错误
2021-05-14
HDU - 4109 Instrction Arrangement
2021-05-14
服务器响应json字符串采用拼接的方式响应时要注意的坑!
2021-05-14
一行代码
2021-05-14
Lua websocket长连接
2021-05-14
SQL 分页查询 返回总条数
2021-05-14
重写的特点
2021-05-14
4、用户及文件权限
2021-05-14
富士电机漏洞预警
2021-05-14
WIFI攻击研究一
2021-05-14
【数据库】MySQL导入文件与导出文件
2021-05-14
计算机网络UDP协议和TCP协议
2021-05-14
Qt中的QGridLayout网格布局类下的两种不同的addWidget功能
2021-05-14
Linux运行C语言文件
2021-05-14
C字符串高级
2021-05-14
2010-03-25 函数题
2021-05-14
C语言_动态内存分配练习
2021-05-14
Linux学习_系统进程概念
2021-05-14
七层网络模型(待添加)
2021-05-14
考研复试——KY276 Problem C
2021-05-14