As you will see in the minimal example below, I use knitr::spin()
with global option dev=c('png','svg')
. The reason is that I want the PNG
in the report rather than the SVG
, as I am worried that the latter will make my browser slow (my plots often have thousands of datapoints), but still want the SVG
for preparing presentations, etc., where I want resolutions that the PNG
can not offer (see footnote).
So my question is: is there a way to put all PNGs into /figure/, and all SVGs into another directory (e.g. /figure/SVGs/ or /SVGs/)?
Here is the minimal example using some spin syntax, but what counts is the line with opts_chunk
:
#+ RglobalOptions, include=FALSE
opts_chunk$set(width=180,dev=c('png', 'svg'))
#+ plottingCode
plot(1:5,1:5)
Note that I have tried fig.path=c('figure/', 'figure/SVGs/')
, but this produces the following error:
Error in dir.create(dirname(name), recursive = TRUE) : invalid 'path' argument
Looking forward to your answers!
Felix
footnote: while I could set fig.width/height to 14 or so, this makes dots, font size etc. awkwardly small; and while there are options to change this awkwardly, outputting an SVG as well is elegant and effective