如何在使用RMarkdown的投影仪演示中从一个代码块中创建两个图?

问题描述 投票:0回答:1

我想从一个RMarkdown文档中的一个R代码块创建多个绘图。输出格式为Beamer-Presentation,我通过在RStudio中点击编织按钮来编织文档。这是一个最小的示例,其中仅创建一个包含一个图的幻灯片,而省略第二个图。我想看两张幻灯片,每张一张图。

---
title: "2 Plots"
output: beamer_presentation
---

# Slide with Plot
```{r cars, echo = TRUE, eval = TRUE}
plot(cars$speed)
plot(cars$dist)
```
r r-markdown knitr beamer
1个回答
0
投票

如果您希望将图放置在单独的幻灯片上,则必须将图放置在单独的块和幻灯片中:

---
title: "2 Plots"
output:
  beamer_presentation: default
  ioslides_presentation: default
---

# Slide with first Plot
```{r cars, echo = TRUE, eval = TRUE}
plot(mtcars$cyl)
```

# Slide with second Plot
```{r cars2, echo = TRUE, eval = TRUE}
plot(mtcars$hp)
```
© www.soinside.com 2019 - 2024. All rights reserved.