Skip to content

input line length in Sweave

2 messages · Woodrow Setzer, Friedrich Leisch

#
I am having trouble in Sweave with input line lengths.  For example, I may have in my input file the chunk

<<>>=
BrainSections <-
  levels(AggData$sctn)[grep(
    "(^BRAIN)|(^WHOLEBRAIN)|(LEFT HEMISPHERE)| (HALFBRAIN)",
                            levels(AggData$sctn))]

@ 

This is translated in the tex file:

\begin{Sinput}
+     levels(AggData$sctn))]
\end{Sinput}

The problem is that the line produced is too long.  I read the answer to the Sweave FAQ question 13 (How can I change the line length of S input and output?) to mean that options(width) controls both input and output; however, the first code chunk in the above example contains 
<<>>=
options(width=66)

@

Is there a way to get Sweave to wrap long input lines better, or get it to use my own formatting of the input?  I realize I can edit the output tex file, but that is impractical in my application (too many).

I am using R version 2.0.1 Patched (2005-01-26) on a Linux system (so, I suppose one possible answer is that this is fixed in 2.1.0; I cannot switch right now).


Woodrow Setzer
National Center for Computational Toxicology
US Environmental Protection Agency
Research Triangle Park, NC 27711
#
> I am having trouble in Sweave with input line lengths.  For example, I may have in my input file the chunk

[...]

  > Is there a way to get Sweave to wrap long input lines better, or
  > get it to use my own formatting of the input?  I realize I can
  > edit the output tex file, but that is impractical in my
  > application (too many).

  > I am using R version 2.0.1 Patched (2005-01-26) on a Linux system
  > (so, I suppose one possible answer is that this is fixed in 2.1.0;
  > I cannot switch right now).

No, no changes in 2.1 with respect to that problem. I have plans for a
solution for this problem, but won't have time for it before summer
break -> in 2.2 there should be a fix for it.

Best,
Fritz