[Rd] keep.source when semicolons separate statements on the one line
Duncan Murdoch
murdoch.duncan at gmail.com
Sat Feb 5 22:02:54 CET 2011
On 05/02/2011 1:18 PM, Duncan Murdoch wrote:
> On 04/02/2011 3:34 PM, Kevin R. Coombes wrote:
>> This is probably the same underlying bug, but it is not caused by
>> semicolons.
>
> Yes, it was the same bug. I think I have it fixed now, and will commit
> after some more testing.
Now committed as r54232 in R-devel. I will wait a couple of days before
backporting it to R-patched, in case new problems show up.
This should also fix the long-standing problem of dropped comments at
the start and end of code chunks. Now, all comments should be echoed,
even in nested named chunks and with \SweaveInput.
Duncan Murdoch
>
> Duncan Murdoch
>
>>
>> If you use keep,soure=TRUE with expand=FALSE and interpolate a code
>> chunk, the name of the chunkl is sent to the TeX file once for every
>> line in the chunk. Specifically, the source file:
>>
>> %%%%%%%%%%%
>> \documentclass{article}
>> \begin{document}
>> <<example>>=
>> x<- 1
>> y<- 2
>> x+y
>> @
>> <<keep.source=TRUE,expand=FALSE>>=
>> <<example>>
>> @
>> \end{document}
>> %%%%%%%%%%%
>>
>> produces the output LaTeX file:
>>
>> %%%%%%%%%%%
>> \documentclass{article}
>> \usepackage{Sweave}
>> \begin{document}
>> \begin{Schunk}
>> \begin{Sinput}
>> > x<- 1
>> > y<- 2
>> > x + y
>> \end{Sinput}
>> \begin{Soutput}
>> [1] 3
>> \end{Soutput}
>> \end{Schunk}
>> \begin{Schunk}
>> \begin{Sinput}
>> > <<example>>
>> > <<example>>
>> > <<example>>
>> \end{Sinput}
>> \begin{Soutput}
>> [1] 3
>> \end{Soutput}
>> \end{Schunk}
>> \end{document}
>>
>> %%%%%%%%%%%
>>
>>
>>
>>
>> On 2/4/2011 7:56 AM, Duncan Murdoch wrote:
>>> Thanks for the report. I'll take a look.
>>>
>>> I'm now past one major time sink, and will have some time to catch up
>>> on old problems; I'll add this to that list.
>>>
>>> Duncan Murdoch
>>>
>>> On 03/02/2011 7:09 PM, John Maindonald wrote:
>>>> The following is 'semicolon.Rnw'
>>>>
>>>>> \SweaveOpts{engine=R, keep.source=TRUE}
>>>>>
>>>>> <<xycig-A, eval=f, echo=f>>=
>>>>> library(SMIR); data(bronchit); library(KernSmooth)
>>>>> @ %
>>>>>
>>>>> Code for panel A is
>>>>> <<code-xycig-A, eval=f, echo=t>>=
>>>>> <<xycig-A>>
>>>>> @ %
>>>>
>>>> Sweave("semicolon") yields the following 'semicolon.tex'
>>>>
>>>>> Code for panel A is
>>>>> \begin{Schunk}
>>>>> \begin{Sinput}
>>>>>> library(SMIR); data(bronchit); library(KernSmooth)
>>>>>> library(SMIR); data(bronchit); library(KernSmooth)
>>>>>> library(SMIR); data(bronchit); library(KernSmooth)
>>>>> \end{Sinput}
>>>>> \end{Schunk}
>>>>
>>>> (I have omitted three blank lines at the start)
>>>>
>>>> With keep.source=FALSE, the commands are split onto
>>>> separate lines, and there is no repetition.
>>>>
>>>> John Maindonald email: john.maindonald at anu.edu.au
>>>> phone : +61 2 (6125)3473 fax : +61 2(6125)5549
>>>> Centre for Mathematics& Its Applications, Room 1194,
>>>> John Dedman Mathematical Sciences Building (Building 27)
>>>> Australian National University, Canberra ACT 0200.
>>>> http://www.maths.anu.edu.au/~johnm
>>>>
>>>> ______________________________________________
>>>> R-devel at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
More information about the R-devel
mailing list