On Jul 30, 2010, at 4:13 AM, soeren.vo...@eawag.ch wrote:
Hello, when I print x in Sweave, the lines do not wrap. However, I want them
to wrap (perhaps at a specified width). How? Thanks, *S*
keep.source=TRUE=
x - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
print(x)
@
See ?strwrap and ?paste. Also use cat() instead of print().
The double \\ at the end of each line tells LaTeX to force a line break.
Since R will detect the \ as an escape character, you need to double them
when cat()ing. I also add a newline (\n) so that the output after the \\
goes to the next line.
cat(paste(strwrap(x, width = 70), collapse = \n), \n)
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do\\
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim\\
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut\\
aliquip ex ea commodo consequat. Duis aute irure dolor in\\
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\\
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\\
culpa qui officia deserunt mollit anim id est laborum.
HTH,
Marc Schwartz
__
R-help@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.