如何用R代码编织Rmd文件生成word文档
How to Knit a Rmd file with R code to generate a word document
我创建了一个 Rmd 文件,我知道如果我转到工具栏和 select "knit to word" 它会生成一个 word 文档。
我的问题是如何使用 R 代码执行此操作而不必实际单击顶部工具栏上的 "knit to word" 选项?
我有这段代码,但它创建的 word 文档不起作用
library(knitr)
knit("AutomationPricingReport.Rmd", "AutomationPricingReport.docx")
你可以这样做
rmarkdown::render("AutomationPricingReport.Rmd",
output_file = "AutomationPricingReport.docx"
)
您可以在文档顶部的 YAML 元数据中指定 output: word_document
。
我创建了一个 Rmd 文件,我知道如果我转到工具栏和 select "knit to word" 它会生成一个 word 文档。
我的问题是如何使用 R 代码执行此操作而不必实际单击顶部工具栏上的 "knit to word" 选项?
我有这段代码,但它创建的 word 文档不起作用
library(knitr)
knit("AutomationPricingReport.Rmd", "AutomationPricingReport.docx")
你可以这样做
rmarkdown::render("AutomationPricingReport.Rmd",
output_file = "AutomationPricingReport.docx"
)
您可以在文档顶部的 YAML 元数据中指定 output: word_document
。