R tip #4: R Markdown: how to get separate image files from html output

One annoyance of html creation from R Markdown is that by default, one gets inline html images. This may seem advantageous – it leads to a single html file. But this leads to a very large html file. Also, one doesn’t have access to the images directly.

Having an html file with separated images is the standard way of doing things. Also, you often want the actual image files for use in presentations or to pass to a colleague or other needs.

Here is a sample header (note yaml format) necessary to force Rmarkdown to produce an html file that has a separate file of images. Note that the “self-contained” is the key part – and the spacing may also be important.

title: "MarkBieda_RLEARN1_RmdWordpressv05"
author: "markb"
date: "December 12, 2016"
output: 
  html_document: 
    self_contained: no

Leave a comment