How to convert R Markdown to HTML? I.e., What does “Knit HTML” do in Rstudio 0.96?

后端 未结 4 1155
感情败类
感情败类 2020-11-27 12:09

What commands are run when pressing \"Knit HTML\" on an R Markdown file in Rstudio 0.96?

My motivation is that I might want to run the same command

4条回答
  •  误落风尘
    2020-11-27 12:50

    Very easy command line method from knitr in a knutshell:

    R -e "rmarkdown::render('knitr_example.Rmd')"
    

    This requires rmarkdown to be installed with install.packages(rmarkdown) and that pandoc is installed (apparently it comes with Rstudio, see knitr in a knutshell for more details).

    So far when I've used this it nicely puts all the plots in the HTML file rather than as images in a figure directory and cleans up any intermediate files, if any; just like compilation in RStudio does.

提交回复
热议问题