Merge branch 'main' of https://github.com/hadley/r4ds
This commit is contained in:
commit
3fe4fafc98
|
@ -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.
|
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.
|
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.
|
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:
|
Then you can write:
|
||||||
|
|
||||||
``` {{r}}
|
``` {{r}}
|
||||||
#| label: raw-data
|
#| 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")
|
rawdata <- readr::read_csv("a_very_large_file.csv")
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue