How to Save the wordcloud in R

13k Views Asked by At

Can you please help to save word cloud on my local drive as an image?, I am looking for a code/command to get it done automatically through R Programming. I have tried with saveWidget, plotly, orca but not get success.

I have used below code to create the word cloud.

library(wordcloud2)
wordcloud2(demoFreqC, figPath = figPath,color = "orangered",fontFamily = "Miso")
3

There are 3 best solutions below

1
On

If you are using RStudio, there is an option to import the output as image on the IDE itself.

6
On

The procedure is outlined here. Briefly:

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 = 1992, vheight = 1744, delay =10)
1
On

in R studio there is an option to export the plot in JPG or PNG format with the image size you want.