Suppose that I use knitr, I have a chunk which takes a while to run, I want this chunk to update if a file changes but not if I e.g., change fig.path. The later suggest that I should change the cache chunk option to 1 but then I cannot use a check sum as suggested here.
Here is an example of a markdown file
---
title: "Example"
author: "Benjamin Christoffersen"
date: "September 2, 2018"
output: html_document
---
```{r setup, include=FALSE}
data_file <- "~/data.RDS"
knitr::opts_chunk$set(echo = TRUE, cache.extra = tools::md5sum(data_file))
```
```{r load_data}
dat <- readRDS(data_file)
```
```{r large_computation, cache = 1}
Sys.sleep(10)
Sys.time() # just to that result do not change
```
```{r make_some_plot}
hist(dat)
```
Running set.seed(1): saveRDS(rnorm(100), "~/data.RDS") and knitting yields
Then running set.seed(2): saveRDS(rnorm(100), "~/data.RDS") and knitting yields
showing that large_computation is not updated as is should not since cache.extra is not in the knitr:::cache1.opts vector. Of course, I can save the md5sum result, check the previous stored file and use cache.rebuild or do something similar in the large_computation chunk but it would be nice with a knitr solution. I often find that I change some chunk options (e.g., dpi, fig.width, and fig.height) so using cache = TRUE will not work. I guess one could modify the package to be able to add options to knitr:::cache1.opts.

