• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

R语言学习笔记(二)词云图绘制

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

运用wordcloud函数

一、wordcloud函数介绍

函数帮助:通过help("wordcloud")查看

wordcloud(words,freq,scale=c(4,.5),min.freq=3,max.words=Inf,
random.order=TRUE, random.color=FALSE, rot.per=.1,
colors="black",ordered.colors=FALSE,use.r.layout=FALSE,
fixed.asp=TRUE, ...)
Arguments


words              
 the words
freq                        their frequencies
scale                A vector of length 2 indicating the range of the size of the words.
min.freq               words with frequency below min.freq will not be plotted
max.words      Maximum number of words to be plotted. least frequent terms dropped
random.order      plot words in random order. If false, they will be plotted in decreasing frequency
random.color       choose colors randomly from the colors. If false, the color is chosen based on the frequency
rot.per               proportion words with 90 degree rotation
colors               color words from least to most frequent
ordered.colors     if true, then colors are assigned to words in order
use.r.layout       if false, then c++ code is used for collision detection, otherwise R is used
fixed.asp               if TRUE, the aspect ratio is fixed. Variable aspect ratio only supported if rot.per==0
...
(二)参数中文介绍:

(1)words——关键词列表
(2)freq——关键词对应的词频列表
(3)scale——字号列表。c(最大字号, 最小字号)
(4)min.freq——最小限制频数。低于此频数的关键词将不会被显示。
(5)max.words——限制词云图上关键词的数量。最后出现在词云图上的关键词数量不超过此限制。
(6)random.order——控制关键词在图上的排列顺序。T:关键词随机排列;F:关键词按频数从图中心位置往外降序排列,即频数大的词出现在中心位置。
(7)random.color——控制关键词的字体颜色。T:字体颜色随机分配;F:根据频数分配字体颜色。
(8)rot.per——控制关键词摆放角度。T:水平摆放;F:旋转90度。
(9)colors——字体颜色列表
(10)ordered.colors——控制字体颜色使用顺序。T:按照指定的顺序给出每个关键词字体颜色,(似乎是要求颜色列表中每个颜色一一对应关键词列表);F:任意给出字体颜色。
(11)use.r.layout=T;F

(三)使用案例

1.安装程序包
install.packages("wordcloud")

2.加载程序包
library(wordcloud)

3.读取数据


data3=read.csv("E:/test45.csv")

4.运行函数

wordcloud(data3$words,data3$freq,scale=c(3,0.3),min.freq=-Inf,max.words=Inf,colors=brewer.pal(8,'Set1'),random.order=F,random.color=F,ordered.colors=F)

5.运行结果




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap