I am working on a two-column (Rnw, latex) document where the width is at a premium. By default knitr indents the code blocks by 4 spaces. How can I reduce this default indentation?
Many thanks David
Either do not reformat the code (use the chunk option tidy=FALSE
) and manually indent by two spaces,
<<tidy=FALSE>>=
if (TRUE) {
# code here
}
@
or set the R option reindent.spaces
to a smaller value, e.g.
options(reindent.spaces = 2)
This option is passed to the formatR package to reindent your code, and knitr uses formatR to reformat your R code by default.
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