This commit is contained in:
mine-cetinkaya-rundel 2023-05-26 16:04:47 -04:00
commit 3fe4fafc98
1 changed files with 2 additions and 2 deletions

View File

@ -637,12 +637,12 @@ Knitr will update the results for the cached chunk whenever it detects that one
Note that the chunks won't update if `a_very_large_file.csv` changes, because knitr caching only tracks changes within the `.qmd` file.
If you want to also track changes to that file you can use the `cache.extra` option.
This is an arbitrary R expression that will invalidate the cache whenever it changes.
A good function to use is `file.info()`: it returns a bunch of information about the file including when it was last modified.
A good function to use is `file.mtime()`: it returns when it was last modified.
Then you can write:
``` {{r}}
#| label: raw-data
#| cache.extra: file.info("a_very_large_file.csv")
#| cache.extra: !expr file.mtime("a_very_large_file.csv")
rawdata <- readr::read_csv("a_very_large_file.csv")
```