avoid error (#1504)

Co-authored-by: Mine Cetinkaya-Rundel <cetinkaya.mine@gmail.com>
This commit is contained in:
Mitsuo Shiota 2023-05-27 04:44:25 +09:00 committed by GitHub
parent 75818986ca
commit 4fc2e09a10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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")
```