I have recently picked up R and while most of it has been a fairly straightforward process, the final step in my little script based on the wordcloud2
package for R is proving to be difficult. I want to create word clouds - which works perfectly - but I was looking into using image masks as the shape for said word clouds, which is where I'm stuck. Similarly, if I'm using the lettercloud
function, I have the same result.
In both cases, the image (or the letter) is displayed in its actual shape, rather than the words that should be displayed on top of them.
For clarification, I am referring to the image mask & lettercloud functions as shown here (illustrated): https://www.r-graph-gallery.com/the-wordcloud2-library/
My code for the image mask word cloud looks as follows:
wordcloud2(myData,
figPath = "C:/R Projects/Word Cloud - Template/Cool/default.png",
size = 1.5, color = "skyblue", backgroundColor="black")
And for the lettercloud:
letterCloud(myData, word = "S", color='random-light' , backgroundColor="black")
I can remove all other parameters like size or color, but they all work, just not the shape changing.
Here is a full code snippet which should make the lettercloud reproducible. wordcloud2
is the only required package; demoFreq is a data.frame that comes with this package:
library(wordcloud2)
letterCloud(demoFreq, word = "S", color='random-light' , backgroundColor="black")
Some additional details & things I've tried so far:
- I'm using RStudio 1.1.442 & R 3.4.4.
- I've tried reinstalling the
wordcloud2
package directly from its source usingdevtools
- I've tried viewing the output in various browsers, refreshing the image several times, but it always just shows the same wordless shape
- Tried with several data.frames, both the ones included with the
wordcloud2
package and my own
Thanks in advance!