R MARKDOWN演示:每张幻灯片中显示一个图

发布于 2025-02-11 18:01:47 字数 305 浏览 0 评论 0原文

我有300个图的列表,希望一个PowerPoint幻灯片显示一个图(300个幻灯片)。实现这一目标的最佳方法是什么?

一个玩具示例,使用内置的IRIS数据集创建一个曲线列表:

purrr::map(names(iris[,-5]), function(col_name){
  plot = iris %>% 
    ggplot(aes(x = !!as.name(col_name))) + 
    geom_histogram()
  return(plot)
})

我希望在每个幻灯片上创建一个图块。

I have a list of 300 plots and want one PowerPoint slide to show one plot (300 slides). What's the best way to achieve this?

A toy example using the built-in iris dataset to create a list of plots:

purrr::map(names(iris[,-5]), function(col_name){
  plot = iris %>% 
    ggplot(aes(x = !!as.name(col_name))) + 
    geom_histogram()
  return(plot)
})

I hope to create PowerPoint slides with one plot on each slide.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌生 2025-02-18 18:01:47

我将使用iris数据集,该数据集通常用于填充示例代码。

使用RMD文件中的以下代码:

---
title: "Test_PowerPoint"
author: "KoenV"
date: '2022-06-30'
output: powerpoint_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

```{r include=FALSE, warning=FALSE, message=FALSE}
library(tidyverse)
library(purrr)
```

```{r, iris, fig.cap="A scatterplot.", echo=FALSE, warning=FALSE, message=FALSE}

## your code    
purrr::map(names(iris[,-5]), function(col_name){
  plot = iris %>% 
    ggplot(aes(x = !!as.name(col_name))) + 
    geom_histogram()
  return(plot)
})

```

键入“针织”按钮后,您将看到PowerPoint演示文稿出现,并带有以下布局:

”

请让我知道,这是什么你想要。

I will be using the iris data set, which is a built-in data set often used to populate example code.

With the following code in a Rmd file:

---
title: "Test_PowerPoint"
author: "KoenV"
date: '2022-06-30'
output: powerpoint_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

```{r include=FALSE, warning=FALSE, message=FALSE}
library(tidyverse)
library(purrr)
```

```{r, iris, fig.cap="A scatterplot.", echo=FALSE, warning=FALSE, message=FALSE}

## your code    
purrr::map(names(iris[,-5]), function(col_name){
  plot = iris %>% 
    ggplot(aes(x = !!as.name(col_name))) + 
    geom_histogram()
  return(plot)
})

```

And after hitting the "knit" button, you will see a PowerPoint presentation appearing, with the following lay-out:

enter image description here

Please let me know, whether this is what you wanted.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文