[R] Problem: Sweave and math environments

Charles C. Berry cberry at tajo.ucsd.edu
Tue Nov 4 23:04:03 CET 2008


On Wed, 5 Nov 2008, David Scott wrote:

> On Tue, 4 Nov 2008, Duncan Murdoch wrote:
>
>>  On 11/4/2008 9:15 AM, Sarah Goslee wrote:
>> >  I'm sure there are a variety of ways around this. My chosen solution
>> >  is to replace
>> > 
>> >  mydata$somevar
>> >  with
>> >  mydata[, "somevar"]
>> > 
>> >  Sarah
>> > 
>>
>>  You should almost never need to modify valid R code to work with Sweave.
>>  (There are a few exceptions:  code that illustrates errors, or code that
>>  requires interaction with a user, etc.)
>>
>>  There's nothing wrong with including mydata$somevar in an Sweave code
>>  chunk.
>>
>>  Duncan Murdoch
>> 
>
> There is nonetheless a point to what she is suggesting. In my experience the 
> $ tends to confuse the editor so the highlighting gets confused amongst other 
> things

If 'the editor' is emacs + ESS, it sometimes happens that the chunk vector 
needs to be updated and that until it is some dollar signs will be seen as 
LaTeX by the syntax highlighting.

If this is your problem,

 	Noweb --> Miscellaneous --> Update the Chunk Vector

or

 	M-n C-l

should fix it.

HTH,

Chuck

>
> David Scott
>
> _________________________________________________________________
> David Scott	Department of Statistics, Tamaki Campus
> 		 The University of Auckland, PB 92019
> 		 Auckland 1142,    NEW ZEALAND
> Phone: +64 9 373 7599 ext 86830		Fax: +64 9 373 7000
> Email:	d.scott at auckland.ac.nz
>
> Graduate Officer, Department of Statistics
> Director of Consulting, Department of Statistics
>
> ______________________________________________
> 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.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901



More information about the R-help mailing list