0

I'm working on a project in R that involves a lot of wordclouds (using wordcloud2) being generated, most of them in their own chunks. Within the R markdown itself, everything works and appears fine. However, when I knit the markdown into an html file, only the first three wordclouds show up. After doing a little testing, it appears this is not an issue with any of the particular wordclouds--if I add include=F to any of the first three wordcloud chunks, thereby removing it from the knitted html, the fourth wordcloud will show up, so that there are still 3 in the knitted html. The knitted html will still have white space sized for any wordcloud it doesn't display (after the first three), but nothing will occupy it. If I increase the figure dimensions for that chunk, the white space size will increase but still no wordcloud. I'd love to figure this out so that the html shows everything I've told it to.

Thanks!

Edit: reproducible code:

trial <- structure(list(word = c("ran", "came", "down", "again", "far", 
"flowed", "looked", "said", "saw", "suddenly", "ago", "already", 
"back", "busy", "capable", "cast", "clear", "constant", "cool", 
"dark", "did", "dived", "divided", "downhill", "driven", "endless", 
"falling", "filled", "floating", "flowing", "formless", "found", 
"gently", "going", "grey", "had", "heard", "here", "Here", "horrible", 
"however", "issued", "Just", "laid", "lay", "leaping", "led", 
"lived", "loomed", "made", "many", "much", "murmuring", "narrow", 
"noisily", "old", "out", "proudly", "reached", "running", "sad", 
"same", "sank", "shining", "silver", "skilfully", "slipped", 
"slow", "sluggish", "smooth", "south", "spilled", "spreading", 
"strong", "swiftly", "thought", "together", "tortuous", "used", 
"wandered", "were", "white", "wished", "woke", "wormed"), n = c(6L, 
5L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L)), row.names = c(NA, -85L), class = c("tbl_df", 
"tbl", "data.frame"))

require(wordcloud2)

 
wordcloud2(trial)

wordcloud2(trial)

wordcloud2(trial) #these three should each be in their own chunks

  • 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 and desired output that can be used to test and verify possible solutions. – MrFlick Apr 16 '21 at 05:23
  • 1
    You might need to save it as image to use it https://stackoverflow.com/questions/47850921/is-there-any-way-to-show-a-wordcloud2-in-rmarkdown-as-a-pdf-or-word-file – Ronak Shah Apr 16 '21 at 06:09
  • You talk about a 4th wordcloud, but your code only has 3 wordclouds. Can you upload a screenshot of your doc and show us more of what you are trying to do? I can run your code and get the wordclouds, so I don't understand what the issue is exactly. – Daniel_j_iii Apr 16 '21 at 19:49

0 Answers0