【发布时间】:2021-01-25 11:53:20
【问题描述】:
我在 R 中有一个代码,在 rMarkdown 中完成,它需要运行多次,但参数值不同。
我该如何解决?我已经举了一个简化问题的例子。
假设我需要在一个循环中打印不同的值,为了简单起见,我使用了简单的循环。
对于这两个循环的每个组合,我想制作一个 html 文件,例如表示 200 *400 个不同的 html 报告文件。
---
title: "file1"
author: "user"
date: "25 1 2021"
output: html_document
---
# The first loop should be done, from 1:100, 101:200 ... to ... 20001:20100
```{r}
i=getfirst()
j=getsecond()
```
```{r}
for (i in i:j) print(i)
```
# The second loop should be done, from 1:50, 51:100 ... to ... 20001:20050
```{r}
for (i in i-50:j-50) print(i)
```
假设每次我们可能有不同的 i 和 j 应该传递到 markdown 文件中。
【问题讨论】:
标签: r r-markdown