This is part four of our four part series Part 1: Specifying the correct figure dimension in {knitr}. Part 2: What image format should you use for graphics. Part 3: Including external graphics in your document Part 4: Setting default {knitr} options (this post). As with many aspects of programming, when you are working by yourself you can be (slightly) more lax with styles and set-up. However, as you start working in a team, different styles can quickly become a hindrance and lead to errors.
rmarkdown
This is part three of our four part series Part 1: Specifying the correct figure dimension in {knitr}. Part 2: What image format should you use for graphics. Part 3: Including external graphics in your document (this post). Part 4: Setting default {knitr} options. In this third post, we’ll look at including eternal images, such as figures and logos in HTML documents. This is relevant for all R markdown files, including fancy things like {bookdown}, {distill} and {pkgdown}.
In our recent post about saving R graphics, it became obvious that achieving consistent graphics across platforms or even saving the “correct” graph on a particular OS was challenging. Getting consistent fonts across platforms often failed, and for the default PNG device under Windows, anti-aliasing was also an issue. The conclusion of the post was to use grDevices::cairo_pdf() for saving PDF graphics or grDevices::png(..., type = "cairo_png") for PNGs or alternatively the new {ragg} package.
R is known for it’s amazing graphics. Not only {ggplot2}, but also {plotly}, and the other dozens of packages at the graphics task view. There seems to be a graph for every scenario. However once you’ve created your figure, how do you export it? This post compares standard methods for exporting R plots as PNGs/PDFs across different OSs. As R has excellent cross-platform capabilities, we may expect this to follow through to exporting graphics.
Recent Posts
- Using Google Lighthouse for Web Pages
- Training Lineup for 2024: January-June
- Getting started with theme()
- Python Virtual Environments and Barbie
- SatRdays London 2024
- Sluggish system or client code?
- Highlights from Shiny in Production (2023)
- An Introduction to Python Package Managers
- Shiny in Production: Sponsors
- Reproducible reports with Jupyter