0

I'm running the latest stable versions of RStudio and R, and have long been using Export-> Save as Image (above the plot viewer). However, a current project requires me to create code that runs itself and outputs image files.

I have a list of words and frequencies, and have produced a wordcloud (library(wordcloud),library(wordcloud2)) with the following code:

wordcloud2(data=TweetData,size=1.6,color='random-dark')

Of course, this produces an image in the viewer, but now I need to save the image on my local drive (as png, jpg, etc.). I tried the following code:

png("tweetdata.png")
wordcloud2(data=TweetData,size=1.6,color='random-dark')
dev.off()

but nothing happens -- no file is saved anywhere (I searched in the wd directory as well as my entire computer. Dev.off() simpy returns "Rstudio GD2" or "NULL DEVICE 1." What is going wrong? I've also tried lots of other variations of this method, ex: dev.new(), etc.

inh2102
  • 11
  • 1
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Feb 27 '20 at 17:43
  • Seems related to: https://github.com/Lchiffon/wordcloud2/issues/8. The `wordcloud2` function creates an interactive web page rather than a static image. Does the regular `wordcloud` function not do what you want? Note that `wordcloud` package is different from the `wordcloud2` package. – MrFlick Feb 27 '20 at 17:46

0 Answers0