After doing all of my analyses in R scripts, I'm now looking to write an R Markdown report. I have previously saved my images in png but I'm wondering if including the code (which the arrangement would be painful) in order to ouput graph directly in R markdown is a better way of doing it ?
Yes, definitely. That is the intended use of rmarkdown.
I save the plots as png and then insert them into the Rmd document for two reasons.
Firstly, the processes I run tend to be too large to be computed in one go, so I run separate processes, one of which saves the plots. These can then be simply inserted into the Rmd document using knitr::include_graphics()
.
Secondly, I found it difficult to match all the dimensions and dpi settings I needed for the plots using Markdown directly, which is most likely my fault.
However, if you don't have these requirements then using RMarkdown directly is the more straightforward method.
Just a side note about this, I think this issue can be overcome by using rmarkdown's built in caching capabilities, that way you don't need to re run computationally expensive code chunks unless is needed.
Hello, thanks for your response.
I assume then that yes, I would need caching as mentioned by another user, but also, that arranging plots directly in R Markdown using for example ggarrange from ggpubr package would maybe fit the document better than separately and pasting the pictures together ?
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.