首页 > 解决方案 > knitr::opts_current: 什么时候可以安全使用?

问题描述

这实际上是opts_current 的副本:它在 knitr 中是如何工作的?,但我正在寻找更广泛的答案。

我喜欢使用一般的 knitr 配方

```{r fig-this-one, fig.scap=current_scaption, fig.cap=current_caption, eval.after=c("fig.scap", "fig.cap")}
ggplot(mydata, aes(x=x, y=y)) + geom_point()
current_scaption <- "My short caption"
current_caption <- "My long caption"
```

opts_current$set()文档让我非常担心会不小心弄乱它,但我很好奇。eval.after使用和有什么区别opts_current$set()吗?基于https://github.com/yihui/knitr/issues/1656,似乎还可以。

标签: rknitr

解决方案


推荐阅读