Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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")
like image 263
Juan Lozano Avatar asked Sep 24 '18 19:09

Juan Lozano


1 Answers

You can do something like this

rmarkdown::render("AutomationPricingReport.Rmd", 
                  output_file = "AutomationPricingReport.docx"
                 )
like image 156
Tung Avatar answered Sep 30 '22 19:09

Tung