I guess you were just looking for an option to control the width of your source code? Setting the width is very tricky with tidy = TRUE
; you often have to try different values to get an appropriate width. You can use the tidy.opts
option to pass the width.cutoff
argument to formatR::tidy.source()
, e.g.
\documentclass{article}
\begin{document}
<<HolySnail, tidy.opts=list(width.cutoff=60)>>=
X <- data.frame(p1=c(0,2,0,0,-1,1),
p2=c(3,0,1,1,0,1),
p3=c(0,0,3,2,1,1))
poor_formatting_requires_tidying <- function(x,y,z) { a <- x*y+z; return(a+z) }
@
\end{document}
Note width.cutoff
only sets the minimal width, which means the output may well be wider than your setting. It depends on whether R can really break the code after width.cutoff
characters.
After you struggle more with tweaking the width value, you probably will just go back to tidy = FALSE
...