Can knitr :: spin () select global options?

knitr :: spin () is a great tool for those who prefer to write code first and second. I would like to use it to create documents with a little repetition of code, but a lot of output and text comments. However, every time I turn off the echo and then add text, spin () turns back on again.

Is there anyway for spin () to select global options from r script that it rotates? for example, a conceptual way could be to place

#+ opts_chunk$set(echo=FALSE) 

as the first line, but it does not seem to be recognized by the spin () function. Is there any way to achieve this?

Mark

+8
r knitr
source share
2 answers

Yes, there is a way: as soon as knit 'ing, just set the global parameters in the original settings block.

So, for example, the following lines are just fine, resulting in an output that does not respond to the incoming code.

 #+ setup, include=FALSE opts_chunk$set(echo=FALSE) #+ aChunk plot(rnorm(99)) #+ anotherChunk 1:100 
+5
source share

How does it work to set global parameters, such as the path to the directory of numbers from the command line?

I have something like: Rscript -e "require(knitr)" -e "knitr::spin('script.R')" -e 'knitr::opts_chunk$set(fig.path="./figs")' , but it always stores images in a newly created folder with numbers.

0
source share

All Articles