在 R markdown 中,如果我想将 cahce 保存在文件目录以外的其他目录中。为此,在夹头中,我将指定
{r chunkName, cache=TRUE, cache.path=cache.path = "../cache_filename/"}
但是如何避免输入文件名呢?有没有办法让它title
命名或filename
不带.Rmd?
knitr
cache.path
根据输入文件名自动设置。如果你想以不同的方式做,你可以做这样的事情:
```{r}
origCache <- knitr::opts_chunk$get("cache.path")
base <- sub("_cache/.*$", "", origCache)
cat("The base of the filename is ", base)
knitr::opts_chunk$set(cache.path = paste0(base, "_new_cache"))
```
现在缓存将设置为文件名的基本部分,后跟“_new_cache”。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句