I’m am working on transitioning some reports to r markdown. Our standards include a header and a logo with a two column body for text with all the graphs/viz starting on a new page, which is also in a two column format with up to six graphs per page. The graphs are unrelated so they can’t be grouped as multiple plots in ggplot. Are there any reference materials, or sample code, that you would recommend to get us started on this project? We are stuck on how to code a two column format in r markdown, and how to set up multiple unrelated graphs on one page.
You can find some format with two column layout like pinp that modifies the already existing PNAS model in rticles
. In the latter, there are several model and maybe other are two columns. They are based on LaTeX to produce pdf output - you could use them directly and customise, or look at the code and see how it is done. There is some Latex
that can help also.
If what you want is close to dashboard with text and graph and you want html output, you should look at flexdashboard
that offers a layout feature that you can use to achieve two column layout.
For html_document output, you may also use css layout to customise your output the way you want.
Thanks. Very helpful.
For composing unrelated ggplot2
plots into a single graphic (probably the easiest way to ensure that they are all on the same page), there are now several options:
gridExtra
accomplishes this with itsgrid.arrange()
andarrangeGrob()
functionscowplot
can do this via itsplot_grid()
functionggpubr
hasggarrange()
, which is a wrapper aroundplot_grid()
that adds some functionality- Newer on the scene, the
patchwork
package is not yet on CRAN, but worth checking out. Its entire goal is "to make it ridiculously simple to combine separate ggplots into the same graphic".
This post has some examples of using the first three: