Reputation: 667
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")
Upvotes: 6
Views: 8127
Reputation: 28331
You can do something like this
rmarkdown::render("AutomationPricingReport.Rmd",
output_file = "AutomationPricingReport.docx"
)
Upvotes: 6
Reputation: 3726
You can specify output: word_document
in the YAML metadata at the top of the document.
Upvotes: 5