Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

knitr

sweave

What is the command-line knitr equivalent of R CMD Sweave myfile.rnw?

like image 928
Jeromy Anglim Avatar asked Jun 08 '12 05:06

Jeromy Anglim


1 Answers

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.

%\VignetteEngine{knitr::knitr} 

To see the possible vignette engines in knitr, use

library(knitr) library(tools) names(vignetteEngine(package = 'knitr')) # "knitr::rmarkdown" "knitr::knitr" "knitr::docco_classic" "knitr::docco_linear" 
like image 79
Maiasaura Avatar answered Oct 11 '22 07:10

Maiasaura