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

运用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.运行结果



  • 4
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值