是否有可能创建一个字云与highcharter?

问题描述 投票:0回答:1

我用下面的代码试了一下,但不知何故,它并没有为我工作:

X4是一个数据帧,点N1的字符串,N2每个字计数的数量。

hchart(x4 ,"wordcloud", hcaes(name = "n1", weight = "n2"))
highcharts r-highcharter
1个回答
2
投票

有在highcharter词云的功能,按照此代码

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)))

并且应该得到的东西像下面的图片:enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.