在下一张幻灯片上绘制

Plot on the next slide

我正在用 RMarkdown 准备一些幻灯片,我需要在一张幻灯片上绘制代码,在下一张幻灯片上绘制,所以我经常发现自己在做一些事情

```{r, eval=FALSE}
plot(x ,y)
````

---

```{r, echo=FALSE}
plot(x, y)
```

有没有更优雅的方法来避免重复?

而不是创建一个对象并调用它

```{r}
plt <- plot(x ,y)
````

---

```{r, echo=FALSE}
plt
```

如果您想将所有图拆分为两帧:

---
output: 
  beamer_presentation:
    keep_tex: true
header-includes:
  - \renewenvironment{Shaded}{\begin{onlyenv}<.(1)>\begin{snugshade}}{\end{snugshade}\end{onlyenv}\pause}
---


```{r,  include=TRUE}
plot(pressure)
```