如何使用Excel中的参数列表自动生成多个RMD文件?

发布于 2025-02-02 17:33:28 字数 371 浏览 2 评论 0原文

我希望你一切都好,我告诉你我的问题。我有一个以.RMD格式使用的仪表板,可与Shiny and FlexDashboard一起使用,当我在仪表板内更改参数时,就会生成全新的。

我想做的是使用我在Excel中拥有的某些标识符自动生成300个仪表板,这将是.rmd文件的参数。

有人对如何解决这个问题有近似值吗?

我留下一个图像,红色圆圈中包含的内容是要更改的参数。

I hope you are well, I tell you my problem. I have a dashboard in .RMD format that works with Shiny and Flexdashboard and when I change a parameter inside the dashboard a completely new one is generated.

What I want to do is to automatically generate 300 dashboards with some identifiers that I have in Excel, which would be the parameters of the .RMD file.

Does anyone have an approximation of how to solve this?

I leave an image, what is enclosed in red circles are the parameters to be changed.

enter image description here

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

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

发布评论

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

评论(1

夜司空 2025-02-09 17:33:28

您可以将这些“标识符”的占位符添加为params在您的YAML标题中,然后从Excel中读取它们,然后循环通过它们,将它们传递到您的.rmd使用params rmarkDown :: Render()purr :: map()中的参数。

因此,您可以添加YAML:

---
params:
  identifier: "identifier1"
---

然后您可以编写这样的渲染函数

render_func <- function(x){
  rmarkdown::render("mymarkdown.Rmd", params = list(x))
}

,并传递您从Excel读取的“标识符”的向量,它可能类似于以下内容:

params_list&lt; - c(“ dissideifier1”,“” dissideifier2”,“ dissideifier3”)

,然后调用列表中每个“标识符”或“ param”的渲染函数,从excel:

purrr :: map(params_list,render_func)>

You can add placeholders for these "identifiers" as params in your YAML header, then read them from Excel into R and then cycle through them, passing them to your .Rmd using the params argument in rmarkdown::render() and purr::map().

So to your YAML you would add:

---
params:
  identifier: "identifier1"
---

and then you could write a render function like this

render_func <- function(x){
  rmarkdown::render("mymarkdown.Rmd", params = list(x))
}

and pass the vector of "identifiers" you read in from excel which might resemble this:

params_list <- c("identifier1", "identifier2", "identifier3")

and then call your render function for each "identifier" or "param" in your list read in from Excel:

purrr::map(params_list, render_func)

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