Or do not reformat the code (use the chunk tidy=FALSE parameter) and manually indent two spaces,
<<tidy=FALSE>>= if (TRUE) { # code here } @
or set R reindent.spaces lower value, for example
options(reindent.spaces = 2)
This parameter is passed to the formatR package to reuse your code, and knitr uses formatR to format your default R code.
source share