0

I want to save the wordcloud2 view in Rstudio both as an html and a PNG file.

I am following the answers in this post, with wordcloud2, htmlwidgets and webshot libraries: How to Save the wordcloud in R

    library(wordcloud2)
    library(htmlwidgets)
    library(webshot)
    
    set.seed(1)
    plot <- wordcloud2(word, freq, size = 1,  minRotation = 0, 
                 maxRotation = 0, shuffle = FALSE, 
                 color = rainbow(nrow(word))
    print(plot)
    
    saveWidget(plot, "test.html", selfcontained = FALSE)
    webshot("test.html", "test.png", delay=15)

The problem I am facing is that each of this visualizations are slightly different in terms of the position of the words. Is there a way to avoid this randomness across the saving steps?

Sapiens
  • 1,543
  • 2
  • 14
  • 19
  • There is some randomness involved in the algorith. Try using `set.seed()` with some numeric value before you call the wordcloud function to get the same results. It's difficult to know if that will work specifically without a proper [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – MrFlick Jul 26 '21 at 17:15

0 Answers0