[R] Problem: Sweave and math environments

Duncan Murdoch murdoch at stats.uwo.ca
Tue Nov 4 23:37:37 CET 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

That sounds to me like a bug in your editor.  I'd rather ask whoever 
wrote my editor to fix the bug, rather than changing the formatting of 
the document I'm writing to work around their bugs.

Duncan Murdoch



More information about the R-help mailing list