[R] Seeming failure of options(width=60) -- summary

John C Nash nashjc at uottawa.ca
Tue Mar 27 02:44:54 CEST 2012


While not having a perfect solution, I have made enough progress to be able to declare 
"good enough", thanks in particular to Duncan Murdoch and Yihui Xie.

First, the font can be made smaller so output fits on a line and does not overflow the 
margins. This is accomplished by putting the command

\RecustomVerbatimEnvironment{Soutput}{Verbatim}{fontsize=\small}

in the .Rnw file. \scriptsize makes things even smaller, but it appears also to shift 
things towards the left margin too. The command is slightly changed from Duncan's.

Second, the strings that are giving us trouble can be wrapped. The simplest solutions are 
not always ideal, but seem to avoid margin intrusions. These are to use

   print(strwrap(answer))

or

   cat(strwrap(answer), sep='\n')

A suggestion was to use capture.output() and then process it, which allows more fine 
control, but is a lot more work.

These steps (combined in my case) did a reasonable job on a package vignette I was preparing.

JN



More information about the R-help mailing list