如何在RMarkdown中渲染wordcloud2的输出

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

如何确保wordcloud2::wordcloud2()的输出出现在我的RMarkdown(HTML)文档中?

它在RStudio中渲染得很好,包括在RMarkdown文档的预览中,但是当我用blogdown将它上传到我的netlify网站时,它没有显示(参见here,帖子的底部)。有任何想法吗?

编辑:这是我正在使用的代码。就像我说的,它在RStudio中完美运行,而不是在网站上。

library(tidyRSS)

five38 <- tidyfeed("http://fivethirtyeight.com/all/feed")
library(wordcloud2)

topics <- five38$item_category1 %>% append(five38$item_category2) %>% 
  append(five38$item_category3) %>% 
  append(five38$item_category4) %>% 
  append(five38$item_category5)

Topics <- data_frame(
  words = topics
) %>% 
  filter(!is.na(words)) %>% 
  group_by(words) %>% 
  tally()

wordcloud2(Topics)
r r-markdown blogdown
1个回答
1
投票
```{r}
library(htmlwidgets)
install.packages("webshot")
webshot::install_phantomjs()
library(wordcloud2)
hw = wordcloud2(demoFreq,size = 3)
saveWidget(hw,"1.html",selfcontained = F)
webshot::webshot("1.html","1.png",vwidth = 700, vheight = 500, delay =10)
```
![](1.png)

好吧,我找到了这种方法来解决wordcloud2的作者的这个问题。

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