Is it possible to create a Word Cloud with highcharter?

让人想犯罪 __ 提交于 2019-12-11 15:19:56

问题


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

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

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

回答1:


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



来源:https://stackoverflow.com/questions/52211451/is-it-possible-to-create-a-word-cloud-with-highcharter

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