[R] Sweave question - Setting Soutput code chunks to stay inside page margins?

Duncan Murdoch murdoch.duncan at gmail.com
Thu Jan 19 14:12:41 CET 2012


On 12-01-19 3:24 AM, Tal Galili wrote:
> Hello all,
>
> Sometimes I get to make an R code chunk (in Sweave) which is longer then
> the margins of the page. Is there a way to force it to "go to the next
> line" (in Sweave) once that happens?

Sweave normally uses a verbatim environment, so you have to arrange this 
on the R side.  Setting options(width=60) works in a lot of cases, but 
not in your example below.

Duncan Murdoch

>
> Here are two cases this happens in the resulting .tex file (one is a "hard"
> case, and the other is simpler)
>
> \begin{Schunk}
> \begin{Sinput}
>
>> print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
> \end{Sinput}
> \begin{Soutput}
> [1] "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
> \end{Soutput}
> \end{Schunk}
>
>
> \begin{Schunk}
> \begin{Soutput}
>
> Some Table
>
> Model 1: SCIM_2_total ~ (I(AMS_2_total^3) + I(AMS_2_total^2) +
> AMS_2_total) + fox
>
> Model 2: SCIM_2_total ~ (I(AMS_2_total^2) + AMS_2_total) + fox
>
> \end{Soutput}
> \end{Schunk}
>
>
> I understand this can be "fixed" from the r side by doing something that
> will break lines for outputs, but that will require me to go through any
> relevant print command and modify it (I rather find a global solution,
> naturally...)
>
>
> Thanks,
> Tal
>
>
>
> ----------------Contact
> Details:-------------------------------------------------------
> Contact me: Tal.Galili at gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
> ----------------------------------------------------------------------------------------------
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list