简体   繁体   中英

how to render output of wordcloud2 in RMarkdown

How can I make sure that the output of wordcloud2::wordcloud2() appears in my RMarkdown (HTML) document?

It renders fine in RStudio, including in the preview of the RMarkdown document, but when I upload it to my netlify site with blogdown, it doesn't show (see here , bottom of the post). Any ideas?

Edit: here's the code I'm using. Like I said, it works perfectly in RStudio, just not on the website itself.

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

ok, i found this way to solve this problem from the author of wordcloud2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM