我真的很抱歉,如果在其他地方得到了答案,我无法找到我想要的答案,但是我可能会找错了... < / p>
假设我有一个月份或类似数据的数据集,我想为每个月的数据生成单独的word文档报告。
我可以使用降价方式分别为每个月制作一个word文档:
---
title: "Untitled"
output: word_document
---
```{r}
test <- structure(list(Month = structure(c(5L, 4L, 8L, 1L, 9L, 7L, 6L,
2L, 12L, 11L, 10L, 3L, 5L, 4L, 8L, 1L), .Label = c("April", "August",
"December", "February", "January", "July", "June", "March", "May",
"November", "October", "September"), class = "factor"), Fruit = structure(c(1L,
1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L), .Label = c("Apple",
"Pear"), class = "factor"), Animal = structure(c(1L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L), .Label = c("Elephant",
"Monkey"), class = "factor")), .Names = c("Month", "Fruit", "Animal"
), class = "data.frame", row.names = c(NA, -16L))
test[test$Month == "January",]
```
但是我每个月都需要一个单独的rmd文件。
我找到了如何从R:
制作这个文件library(rmarkdown)
render("test.rmd",output_file = "test.docx", word_document()) # test.rmd is just the above code in a file
但是有没有办法将它们链接在一起并循环几个月才能一次性生成多个报告?
我觉得数据应该放在R文件的列表中,然后循环播放......但我不知道这是否正确(从全球传递信息是不是很糟糕)环境进入降价文件?我觉得它没有这样做是有原因的...有更好的方法吗?)
答案 0 :(得分:0)
我听说过参数化的rapports。可以制作不同的版本。这里讨论了构建具有不同输出的单词和pdf的版本我认为,但也许它可以根据您的需要进行修改?