3
votes

I am using knitr to generate markdown that I then convert to html using markdown::markdownToHTML()

knitr will place figures for .Rmd file in a figure/ subdirectory. If I process multiple .Rmd files in the same directory, however, the figures can get overwritten. Naming each chunk with a name that is unique across all .Rmd files makes uniquely named figures, but that is error prone. Reusing a name by accident will silently overwrite older figures.

Is there an easy way to use different figure/ directories or otherwise separate the figures for each .Rmd file?

1

1 Answers

4
votes

Yes, you can use:

opts_chunk$set(fig.path = "other_directory")

In each document to override the default figure/ path.