-->

How to Save the wordcloud in R [duplicate]

2019-06-08 20:41发布

问题:

This question already has an answer here:

  • Is there any way to show a wordcloud2 in Rmarkdown as a PDF or Word file? 1 answer

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

回答1:

The procedure is outlined here. Briefly:

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)


回答2:

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



回答3:

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