简体   繁体   中英

How to Knit a Rmd file with R code to generate a word document

I have created an Rmd file and I know that if I go to the tools bars and select "knit to word" it will generate a word document form me.

My question is how can I do this with R code without having to actually clicking on the "knit to word" option on the top tool bar?

I have this code but the word document it creates does not work

library(knitr)
knit("AutomationPricingReport.Rmd", "AutomationPricingReport.docx")

You can do something like this

rmarkdown::render("AutomationPricingReport.Rmd", 
                  output_file = "AutomationPricingReport.docx"
                 )

您可以在文档顶部的YAML元数据中指定output: word_document

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM