R语言数据挖掘:词云的绘制

冷暖自知 提交于 2019-12-05 22:37:50

最近的作业是用爬虫扒数据,自己探索做分析。
今天先把项目的文字云素材部分分享一下。

if (!require(devtools)) install.packages('devtools')
devtools::install_github("lchiffon/wordcloud2",force = TRUE)

报错:没有htmltools包
找了网上的教程,修改为:

ibrary(RCurl)
library(httr)
set_config( config( ssl_verifypeer = 0L ) )

if (!require(devtools)) install.packages('devtools')
devtools::install_github("lchiffon/wordcloud2",force = TRUE)

载入成功。

library(wordcloud2)
wordcloud2(demoFreq,size = 1,shape='star')
wordcloud2(demoFreqC,size = 2, fontFamily = "微软雅黑",
           color = "random-light",background = "grey")

报错:不存在“yaml”程序包

install.packages("yaml")
library(yaml)

完整代码

library(RCurl)
library(httr)
set_config( config( ssl_verifypeer = 0L ) )

if (!require(devtools)) install.packages('devtools')
devtools::install_github("lchiffon/wordcloud2",force = TRUE)


install.packages("yaml")
library(yaml)

library(wordcloud2)
wordcloud2(demoFreq,size = 1,shape='star')
wordcloud2(demoFreqC,size = 2, fontFamily = "微软雅黑",
           color = "random-light",background = "grey")

data <- read.csv('D:/数据/高考.csv',sep=",",header = T)
wordcloud2(data, size = 1, shape='round',color = 'random-light',  
           backgroundColor = "grey",fontFamily = "微软雅黑")

高考数据下载链接:http://pan.baidu.com/s/1jI4gEnc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!