[R] R echo code chunk runs off the page using Lyx and Sweave
Duncan Murdoch
murdoch at stats.uwo.ca
Wed Nov 11 00:14:15 CET 2009
Mark Connolly wrote:
> Thanks. I guess it kind of works for me as well. The contents of a
> dataframe will display in the specified width, but doing a
> str(dataframe) will happily run past the width set in options and use up
> the device width (command line). I guess this may be my issue.
> Options(width) does work for displaying the contents of an object (a
> dataframe, for example) in the document, but whatever device geometry
> exists for long lines of R output seems to be wider than my document,
> and long code chunks, str(dataframe) output and the like run past the
> edge of the document page margin when PDF is rendered.
>
> So I guess the question is: Can I set device geometry somewhere so that
> chunks of R code wrap inside a specified width when a document is
> rendered? I am using Lyx, but I think this may be between Latex and R
> (as orchestrated by Sweave). Maybe the answer for Latex is the same
> answer for Lyx.
>
I don't think so. There is a strwrap() function that can do wrapping,
but it might not produce beautiful output.
For example, if x is something where str(x) produces lines that are too
long, you could do
cat(strwrap(capture.output(str(x)), width=20), sep="\n")
to get the results displayed in width 20.
Duncan Murdoch
> Ista Zahn wrote:
>
>> options(width=n) is supposed to work, and does for me. I don't use Lyx though...
>>
>> -Ista
>> On Tue, Nov 10, 2009 at 4:27 PM, Mark Connolly <mark_connolly at acm.org> wrote:
>>
>>
>>> I am not really sure where in the interactions this is handled, but I would
>>> like to keep echo-ed R code chunks from running past the right margin and
>>> off the page. I started with R and options(width=n), but this does not seem
>>> to do anything (in the context of a document -- line command works just
>>> fine). I have beating my head against different Lyx document settings
>>> without anything to show. Anyone point me in the right direction?
>>>
>>> ______________________________________________
>>> 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.
>>>
>>>
>>>
>>
>>
>>
>
> ______________________________________________
> 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