8

Suppose, I have a dataframe which contains some words with their frequencies. I want to create a wordcloud in R with the words inside the shape of a logo, for example, the twitter logo just like this: enter image description here

For the wordcloud, there is a package named wordcloud2 and running the demo only gives a square image of the words. How would I add a specific image of my choice to be the shape of the wordcloud?

wordcloud2(demoFreq) only ouputs a square.

2
  • Ok sorry. typing into google was giving only python solution. Feb 3, 2017 at 16:35
  • 5
    I don't think this question is "asking us to recommend or find a book, tool, software library, tutorial or other off-site resource"
    – axme100
    Nov 16, 2018 at 21:10

1 Answer 1

17

You can use wordcloud2 package for that. It allows you to use any image as the mask. Just put in the working directory and link to it using figpath. Below is the code I used to make the wordcloud. Below that is the wordcloud. Here is the image I used as the mask.

library(wordcloud2)
wordcloud2(demoFreq, figPath = "twitter.jpg")

enter image description here

1
  • can we use it with Quanteda's DFM? Jul 24, 2019 at 10:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.