rknitrknitr-spin

Is there a global command line knit option as eval=FALSE for all chunks?


I quite often make mistakes in the text part of *.Rmd documents and, in some cases, fixing and running knit() implies re-running R commands that can take a while. Therefore, it is an advantage running the .Rmd document without actually executing the R code first, then fix any typos and structure errors and then run again with evaluation. I know this can be achieved by including

knitr::opts_chunk$set(eval = FALSE)

in the .Rmd

but I would prefer avoiding to actually edit the .Rmd file and using an equivalent way at the command line, something like

knit("file.Rmd", eval=FALSE)

Is actually there a way to achieve this at the command line?


Solution

  • You do not need to edit the .Rmd file. You can just run

    knitr::opts_chunk$set(eval = FALSE)
    

    before running knitr::knit(); knitr will respect the global chunk options you set before calling knitr::knit().