[R] \Sweaveopts error

Duncan Murdoch murdoch.duncan at gmail.com
Sun Nov 28 13:47:55 CET 2010


On 27/11/2010 8:59 PM, John Maindonald wrote:
> Actually, I had until I created this file had everything on one line,
> or had separate \SweaveOpts commands.
>
> Putting everything on one line ensures that the graphics file
> goes to the subdirectory snArt, but the file test1.tex is unchanged.
>
> Note however the difference between the files test1.tex and
> test.tex, irrespective of the 1 line or 2 issue.  The first of the
> \SweaveOpts lines had an effect, unless I am missing something.

I'm confused now.  Where does test.tex come from?  It's not in the 
directory referred to below, and I don't see it mentioned earlier in 
this thread.

Duncan Murdoch

>
> John.
>
> 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
>
> On 28/11/2010, at 12:40 PM, Duncan Murdoch wrote:
>
>> On 27/11/2010 7:57 PM, John Maindonald wrote:
>>> Actually, I spoke too soon.  The files process without obvious error,
>>> but keep.source=TRUE is ignored.  I have posted small files
>>> test1.Rnw and test2.Rnw that can be used to demonstrate the
>>> problems at:
>>>    http://wwwmaths.anu.edu.au/~johnm/r/issues/
>>
>> In the test1.Rnw file, your \SweaveOpts statement spans two lines. Sweave() doesn't recognize it, so it's completely ignored.
>>
>> I don't think this is new behaviour; it's a consequence of the way Sweave looks for \SweaveOpts via regular expression.
>>
>> Not quite sure what's going on in the second one yet...
>>
>> Duncan Murdoch
>>
>>>
>>> Sweave("test1")  ## includes SweaveOpts settings
>>>
>>> Sweave("test2", keep.source=TRUE)
>>>                                ## SweaveOpts settings have been removed.
>>>
>>> Comments do not appear in the LaTeX file that results, the code
>>> is reformatted and the graph from test1 goes into the working
>>> directory.
>>>
>>> Notice also the NA that mysteriously appears in the second
>>> line of code in output .tex file test2.tex
>>>
>>> John.
>>>
>>> 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
>>>
>>> On 26/11/2010, at 4:26 PM, John Maindonald wrote:
>>>
>>>> Yes, that has fixed the problem. (2010-11-24 r53659)
>>>>
>>>> Thanks.
>>>>
>>>> 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
>>>>
>>>> On 25/11/2010, at 10:56 PM, Duncan Murdoch wrote:
>>>>
>>>>> On 25/11/2010 6:34 AM, John Maindonald wrote:
>>>>>> I have a file 4lmetc.Rnw, intended for inclusion in a LaTeX document,
>>>>>> that starts:
>>>>>
>>>>> I think this may have been fixed in the patched version.  Could you give it a try to confirm?  If not, please send me a simplified version of the file, and I'll see what's going wrong.
>>>>>
>>>>> Duncan Murdoch
>>>>>
>>>>>
>>>>>>
>>>>>> \SweaveOpts{engine=R, keep.source=TRUE}
>>>>>> \SweaveOpts{eps=FALSE, prefix.string=snArt/4lmetc}
>>>>>>
>>>>>> The attempt to process the file through Sweave generates the error:
>>>>>>
>>>>>>> Sweave("4lmetc")
>>>>>> Writing to file 4lmetc.tex
>>>>>> Processing code chunks ...
>>>>>> 1 : keep.source term verbatim
>>>>>> Error in file(srcfile$filename, open = "rt", encoding = encoding) :
>>>>>> cannot open the connection
>>>>>> In addition: Warning message:
>>>>>> In file(srcfile$filename, open = "rt", encoding = encoding) :
>>>>>> cannot open file '4lmetc': No such file or directory
>>>>>>
>>>>>> The same file processes through Stangle() without problems.
>>>>>> If I comment out the \Sweaveopts lines, there is no problem,
>>>>>> except that I do not get the options that I want.
>>>>>>
>>>>>> This processed fine in R-2.11.1
>>>>>>
>>>>>>> sessionInfo()
>>>>>> R version 2.12.0 (2010-10-15)
>>>>>> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>>>>>>
>>>>>> locale:
>>>>>> [1] C
>>>>>>
>>>>>> attached base packages:
>>>>>> [1] stats     graphics  grDevices utils     datasets  grid      methods
>>>>>> [8] base
>>>>>>
>>>>>> other attached packages:
>>>>>> [1] lattice_0.19-13     DAAG_1.02           randomForest_4.5-36
>>>>>> [4] rpart_3.1-46        MASS_7.3-8          reshape_0.8.3
>>>>>> [7] plyr_1.2.1          proto_0.3-8
>>>>>>
>>>>>> loaded via a namespace (and not attached):
>>>>>> [1] ggplot2_0.8.8       latticeExtra_0.6-14
>>>>>>
>>>>>> Is there a workaround?
>>>>>>
>>>>>> 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-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