Re: [R] Sweave - print \n ?

From: Charilaos Skiadas <cskiadas_at_gmail.com>
Date: Sat, 29 Mar 2008 08:44:35 -0400

Try adding strip.white=false on the code chunks:

<<echo=false,results=tex, strip.white=false>>= hline()
hline()
@

Read ?RweaveLatex for more settings.

or if you want this to happen in all code chunks add this early on in the rnw file:

\SweaveOpts{strip.white=false}

Haris Skiadas
Department of Mathematics and Computer Science Hanover College

On Mar 29, 2008, at 4:54 AM, Werner Wernersen wrote:

> Thanks for your comments!
> I think using just one backslash for \n is correct
> because otherwise I get a "\n" literally printed out
> in the generated .tex code. But what I'm trying to get
> is just a line break, thus that the .tex code
> continues on a new line from the point where I put the
> \n.
>
> All the best,
> Werner
>
>
>
> --- Abhijit Dasgupta <adasgupt_at_mail.jci.tju.edu>
> schrieb:
>
>> you haven't escaped the \ for the \n, I think. Your
>> line should be
>> cat("\\hline \\n"). You did escape the \ for hline,
>> though.
>>
>> Abhijit Dasgupta, Ph.D
>> Assistant Professor | Division of Biostatistics
>> Dept of Pharmacology and Experimental Therapeutics |
>> Thomas Jefferson
>> University
>> 1015 Chestnut St | Suite M100 | Philadelphia PA
>> 19107
>> Ph: (215) 503-9201 | Fax: (215) 503-3804
>> adasgupt (at) mail (dot) jci (dot) tju (dot) edu
>>
> ----------------------------------------------------------------------
> --
>> The documents accompanying this transmission may
>> contain confidential
>> health or business information. This information is
>> intended for the use
>> of the individual or entity named above. If you have
>> received this
>> information in error, please notify the sender
>> immediately and arrange
>> for the return or destruction of these documents.
>>
> ----------------------------------------------------------------------
> --
>>
>>
>> Werner Wernersen wrote:
>>> Hi,
>>>
>>> this is probably quite stupid but I have no clue
>>> what's wrong. Let's say I write the function
>>> hline <- function() {
>>> cat("\\hline \n")
>>> }
>>> and call hline() from within a Sweave chunk. Why
>> is
>>> there no carriage return after the \hline in the
>>> resulting tex file?
>>>
>>> if I call hline() hline() in the chunk, then I get
>>> \hline \hline
>>> in the tex code without a linebreak in between.
>>>
>>> Thanks for any hints,
>>> Werner
>>>



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. Received on Sat 29 Mar 2008 - 12:49:15 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 29 Mar 2008 - 15:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive