[ESS] '$' sign in R code

Douglas Bates bates at stat.wisc.edu
Tue Sep 14 00:48:16 CEST 2010


On Mon, Sep 13, 2010 at 4:54 PM, Tengfei Yin <yintengfei at gmail.com> wrote:
> Hi Sven,
>
> Thanks for your suggestions!!
>
> This works fine for \Sexp{whatever$blabla}, but sometimes I want to show the
> code chunk with $ sign in some case, like a documentation or tutorial that
> describe function of $, I have to put a # $ as a comment after the line I
> use $ sign, so if sometimes I set keep.source=TRUE, the comment will show
> up, and it's not pretty if this workaround s used for publication.
>
> ......when I write this question, I just find another workaround, instead of
> putting a #$ in comment of code chunk, I put a %$ in comment of latex file,
> this looks wired, but it works.

Not too weird.  I always put that %$ construction after the closing @
for the code block so I know why it is there.

> Thanks again!!
>
> Tengfei
>
> On Mon, Sep 13, 2010 at 1:14 PM, Sven Hartenstein
> <lists at svenhartenstein.de>wrote:
>
>> Dear Tengfei,
>>
>> > In a R code chunk, when I use data frame 's $ accessor to subset it,
>> > I have to put another $ in the comment, or the latex will treated as
>> > math mode?
>>
>> This has been discussed before. See this thread:
>> https://stat.ethz.ch/pipermail/ess-help/2009-November/thread.html#5679
>>
>> What I do is thus:
>>
>>  df[df[["X_STATE"]]==6,'X_STATE'] <- 'CA'



More information about the ESS-help mailing list