knitr::spin() is a great tool for those that prefer to write code first and text second. I would like to use it to produce documents with little code echoing, but lots of output and text comments. However, every time that I turn off echoing and then add some text, spin() turns echoing back on again.
Is there anyway for spin() to pick up global options from the r script that it is spinning? e.g.one conceptual way could be putting
#+ opts_chunk$set(echo=FALSE)
as the first line but it doesn't seem to be recognised by spin(). Is there any way to achieve this?
Mark
Having a consistent set of {knitr} options makes standardising figures across documents (slightly) easier. These options control the graphics options. : create a standard directory where generated figures are stored. For our Hugo blog posts, we set
In short: knitr::spin is similar to knitr::knit in that it takes as input a file with R code + formatting + text and produces a nice readable report, such as an HTML or markdown document. The difference lies in the input: spin operates on R scripts ( .R ), while knit requires a literate programming file ( .Rmd, .Rnw, etc.).
I think if the output is very text-heavy and focuses a lot more on formatting and visual, and only includes some bits of R code here and there, then knit would be more appropriate. But if a report is primarily a way to showcase a lot of code, with intermittent text, then spin can save you a lot of trouble.
Using {knitr} is no different. When you work on documents with different team members, it’s helpful to have a consistent set of settings. If the default for changes, this can easily waste time as you try to track down an error.
Yes, there is a way: as when knit
'ing, just set global options in an initial setup chunk.
So, for example, the following spins up just fine, resulting in output that does not echo any of the supplied code.
#+ setup, include=FALSE
opts_chunk$set(echo=FALSE)
#+ aChunk
plot(rnorm(99))
#+ anotherChunk
1:100
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With