是否可以使用高级章程创建词云? [英] Is it possible to create a Word Cloud with highcharter?

查看:85
本文介绍了是否可以使用高级章程创建词云?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的代码尝试了一下,但是不知怎么对我不起作用:

I tried it with the following code, but somehow it didn't work for me:

x4是一个数据帧,n1是一个字符串,n2是每个单词的计数数.

x4 is a dataframe, n1 a character string, and n2 the number of counts per word.

hchart(x4 ,"wordcloud", hcaes(name = "n1", weight = "n2"))

推荐答案

highcharter中有一个词云功能,请遵循此代码

There is a function for word cloud in highcharter, follow this code

data(reuters, package = "kernlab")



text = paste(
reuters[[1]])

textcld <- text %>% 
map(str_to_lower) %>% 
reduce(str_c) %>% 
str_split("\\s+") %>% 
unlist() %>% 
data_frame(word = .) %>% 
count(word, sort = TRUE) %>% 
anti_join(tidytext::stop_words)

hchart(textcld, "wordcloud", hcaes(name = word, weight = log(n)))

并且应该得到类似下图的图像: 在此处输入图片描述

And should get something like the image below: enter image description here

这篇关于是否可以使用高级章程创建词云?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆