Sometimes I had to make more chunks in R markup to "fake" an output in R markup. As an example, since I found out printing a wordcloud2 in R markdown is basically not possible by calling the usual wordcloud2 function, I had to print it out on my pdf but letting it seem like the basic function did it.
```{r}
freq <- data.frame(names(freq),freq, row.names
= 1:length(freq))
library(wordcloud2)
```
```{r eval=FALSE}
wordcloud2(freq,color="random-light", backgroundColor = "grey")
```
```{r echo=FALSE, message=FALSE}
library(htmlwidgets)
webshot::install_phantomjs()
hw = wordcloud2(freq,color="random-light", backgroundColor = "grey")
saveWidget(hw,"1.html",selfcontained = F)
webshot::webshot("1.html","1.png",vwidth = 700, vheight = 500, delay =10)
```
This is what I have done, in simple words I made a non visible chunk print the wordcloud instead of the "graphic" one.
This is the result:
I know that probably nobody would notice, but having the chunks visually separated is not very beautiful.
Is there a way to unify those two?
Thank you in advance.