我正在尝试在新的和漂亮的预览版本的RStudio(.rpres)中自动生成幻灯片。以下代码生成幻灯片,但图表不会显示在幻灯片3及更高版本上。如何包含这些地块?
My First Presentation
========================================================
author: Me
date: Now
Slide 1
========================================================
This is plot 1
```{r, echo=FALSE}
tmp.cars <- cars
tmp.cars$dist <- tmp.cars$dist*1 # Multiplied by 1 because slide 1
plot(tmp.cars)
```
Slide 2
========================================================
This is plot 2
```{r, echo=FALSE}
tmp.cars <- cars
tmp.cars$dist <- tmp.cars$dist*2 # Multiplied by 2 because slide 2
plot(tmp.cars)
```
```{r loop, echo=FALSE, results='asis'}
for(i in 3:10) {
cat(paste("Slide ", i, "\n", sep=""))
cat("========================================================\n")
cat(paste("This is plot ", i, "\n\n", sep=""))
tmp.cars <- cars
tmp.cars$dist <- tmp.cars$dist*i # Multiplied by i because slide i
plot(tmp.cars)
}
```