[R] Changing line length in Sweave output works for numeric, but not for character vectors
Simon Kiss
sjkiss at gmail.com
Tue Aug 21 15:17:07 CEST 2012
Hi: I'm not sure how to do 1, but I also tried strwrap() and that worked OK. Although it's not pretty. But it'll do.
Simon
On 2012-08-20, at 5:52 PM, Yihui Xie wrote:
> Two possible solutions:
>
> 1. Redefine the LaTeX environment so it allows wrapping (see listings
> for example);
> 2. Manually break your long string into shorter pieces and paste()
> them together, e.g. paste('long', 'long', 'string')
>
> Regards,
> Yihui
> --
> Yihui Xie <xieyihui at gmail.com>
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
>
> On Mon, Aug 20, 2012 at 5:03 PM, Simon Kiss <sjkiss at gmail.com> wrote:
>> Hi there: I'm preparing a report in RStudio 0.96.330 on a Mac OS. I'm running R 2.15.0
>>
>> I understand from Ross Ihaka's document (http://www.stat.auckland.ac.nz/~stat782/downloads/Sweave-customisation.pdf) that you can modify the line length of Sweave output by a call to options(wdith=x).
>>
>> This works great for me for numeric output, but not for character vectors that I have to print. The following is some sample code that illustrates my problem.
>>
>> Is there a different way to format character vectors that are stored in R?
>> Yours, Simon Kiss
>>
>> \documentclass{article}
>>
>> \begin{document}
>> \SweaveOpts{concordance=TRUE}
>>
>> <<echo=TRUE, results=verbatim>>=
>> seq(1,100,1)
>> @
>>
>> <<echo=TRUE, results=verbatim>>=
>> options(width=30)
>> @
>> <<echo=TRUE, results=verbatim>>=
>> seq(1,100,1)
>> @
>>
>> <<echo=TRUE, results=verbatim>>=
>> test<-c('The government should do more to advance societys goals, even if that means limiting the freedom and choices of individuals.')
>> @
>>
>> \end{document}
>> *********************************
>> Simon J. Kiss, PhD
>> Assistant Professor, Wilfrid Laurier University
>> 73 George Street
>> Brantford, Ontario, Canada
>> N3T 2C9
>> Cell: +1 905 746 7606
>>
>> Please avoid sending me Word, PowerPoint or Excel attachments. Sending these documents puts pressure on them to use Microsoft software and helps to deny them any other choice. In effect, you become a buttress of the Microsoft
>> monopoly. This pressure is a major obstacle to the broader adoption of free software.
>>
>> To convert to plain text choose Text Only or Text Document as the Save As Type. Your computer may also have a program to convert to PDF format. Select File, then Print. Scroll through available printers and select the PDF converter. Click on the Print button and enter a name for the PDF file when requested.
>>
>> ______________________________________________
>> 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.
*********************************
Simon J. Kiss, PhD
Assistant Professor, Wilfrid Laurier University
73 George Street
Brantford, Ontario, Canada
N3T 2C9
Cell: +1 905 746 7606
Please avoid sending me Word, PowerPoint or Excel attachments. Sending these documents puts pressure on them to use Microsoft software and helps to deny them any other choice. In effect, you become a buttress of the Microsoft
monopoly. This pressure is a major obstacle to the broader adoption of free software.
To convert to plain text choose Text Only or Text Document as the Save As Type. Your computer may also have a program to convert to PDF format. Select File, then Print. Scroll through available printers and select the PDF converter. Click on the Print button and enter a name for the PDF file when requested.
More information about the R-help
mailing list