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

后端 未结 4 1142
感情败类
感情败类 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:47

    Put Sys.sleep(30) in a chunk and you will see clearly what commands are called by RStudio. Basically they are

    1. library(knitr); knit() to get the markdown file;
    2. RStudio has internal functions to convert markdown to HTML;

    The second step will be more transparent in the next version of the markdown package. Currently you can use knitr::knit2html('your_file.Rmd') to get a similar HTML file as RStudio gives you.


    Update on 2019/09/17: The above answer applies to RStudio v0.96 (in the year 2012). Now R Markdown is compiled through rmarkdown::render(), which uses Pandoc instead of the retired R package markdown. See the post Relationship between R Markdown, Knitr, Pandoc, and Bookdown for more details.

提交回复
热议问题