在knitr中缓存内联代码块
有人知道在knitr/rmarkdown中是否以及如何更改内联代码块吗 这是我的出发点,但不起作用:在knitr中缓存内联代码块,r,knitr,r-markdown,R,Knitr,R Markdown,有人知道在knitr/rmarkdown中是否以及如何更改内联代码块吗 这是我的出发点,但不起作用: --- title: "Test of inline chunk caching" output: html_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(cache = TRUE) ``` ## Test of inline chunk caching Test test `r Sys.sleep(10)`
---
title: "Test of inline chunk caching"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(cache = TRUE)
```
## Test of inline chunk caching
Test test `r Sys.sleep(10)` test test
我不知道如何缓存内联代码。但是,您可以创建一段代码,其中包含将在文本和内嵌代码中展开的所有相同变量和计算 只需设置该块以抑制代码、警告和输出的可见性,然后设置
cache=TRUE
。它基本上运行并隐藏结果。然后将数据保存到变量中。通过将变量插入到内嵌代码中,您可以随时调用它。它将在下面的块中保持可用
谢谢。因此,我将这样做,并缓存“行间”块。