Jeromy Anglim Jeromy Anglim - 1 year ago 107
R Question

What is the knitr equivalent of `R CMD Sweave myfile.rnw`?

What is the command-line knitr equivalent of

R CMD Sweave myfile.rnw

Answer Source

The general solution (works regardless of the R version):

Rscript -e "library(knitr); knit('myfile.Rmd')"

Since R 3.1.0, R CMD Sweave has started to support non-Sweave documents (although the command name sounds a little odd), and the only thing you need to do is to specify a vignette engine in your document, e.g.


To see the possible vignette engines in knitr, use

names(vignetteEngine(package = 'knitr'))
# "knitr::rmarkdown" "knitr::knitr" "knitr::docco_classic" "knitr::docco_linear"