我需要生成一个由几个部分组成的报告,所有部分看起来都很相似,只有一些数据差异.部分的数量也取决于数据.我最终想拥有的是这样的:
```{r}
section_names = c("A","B","C")
section_data = c(13,14,16)
```
# some looping mechanism here with variable i
This is section `r section_names[i]`
This section's data is `r section_data[i]`
#more things go here for the section
#end of loop should go here
Run Code Online (Sandbox Code Playgroud)
结果应该是一个单独的html /文档,所有部分一个接一个.
你能指点我用循环生成这样一个Rmd文件的方法吗?
理想情况下,我希望看到像PHP中的东西:
<$php for(i=0;i<10;i++) { ?>
## some html template + code chunks here
<$php } ?>
Run Code Online (Sandbox Code Playgroud)