I have a question regarding the knitr chunk option \"dependson\". As far as I understood the manual this option should be used to specify which other cached chunks a cached
Yes, you can make var
a part of the chunk options, e.g.
<<cached, cache=TRUE, cache.whatever=var>>=
@
cache.whatever
is not an official chunk option name, but you can use arbitrary options in knitr
, and they will affect the cache invalidation. In this case, when var
is updated, the cache will be updated.
If you want var
to affect all cached chunks, you can set it as a global option, but remember to set it as an unevaluated expression:
opts_chunk$set(cache.whatever = quote(var))
You can use arbitrary R expressions inside quote()
, so if you have more variables, you can put them in a list, e.g.
opts_chunk$set(cache.whatever = quote(list(var1, var2)))