[ESS] synthax higlighting \Sexpr in .Rnw files

Douglas Bates bates at stat.wisc.edu
Thu Nov 19 18:05:47 CET 2009


On Thu, Nov 19, 2009 at 8:46 AM, Emanuel Heitlinger
<emanuelheitlinger at googlemail.com> wrote:
> Ohh,
> thanks again!
> this looks less complicated and I will change my subsetting-style...
>
> Emanuel
>
> 2009/11/19, Douglas Bates <bates at stat.wisc.edu>:
>> On Thu, Nov 19, 2009 at 8:31 AM, Emanuel Heitlinger
>> <emanuelheitlinger at googlemail.com> wrote:
>>> Thanks!
>>>
>>> I also thought about that, but did not manage to find a similar
>>> expression for e.g.
>>> \Sexpr{length(exp.tab$coverage[exp.tab$raw.count>0])}
>>> Maybe that is just poor R, but I suppose it would look much more
>>> complicated anyways...
>>
>> \Sexpr{with(subset(exp.tab, raw.count > 0), length(coverage))}

Now that I think about it, you can simplify to nrow(subset(exp.tab,
raw.count > 0)) or even with(exp.tab, sum(raw.count > 0))

>>> I am using Sweave for "non-code-centric" reports (with the idea to
>>> write large parts of my bioinformatics-PhD-thesis in Sweave) with many
>>> /Sexpr and would prefer not to change/complicate my style of
>>> subsetting.
>>>
>>> Yes, ESS for .Rnw editing is great and a main prerequisite for my
>>> reproducible-thesis idea...
>>>
>>> Any other ideas?
>>>
>>> Emanuel
>>>
>>>
>>> 2009/11/19, Douglas Bates <bates at stat.wisc.edu>:
>>>> On Wed, Nov 18, 2009 at 11:24 AM, Emanuel Heitlinger
>>>> <emanuelheitlinger at googlemail.com> wrote:
>>>>> Hi List,
>>>>>
>>>>> editing the .Rnw files of Sweave/Noweb I have a problem with
>>>>> \Sexpr{whatever$name}:
>>>>
>>>> An equivalent, and less problematic, expression is
>>>>
>>>> \Sexpr{whatever[["name"]]}
>>>>
>>>> It's a bit more typing but it doesn't have the problem of LaTeX-mode
>>>> and R-mode fighting over the interpretation of the $ symbol.
>>>>
>>>> In some ways the surprising thing about a hybrid like Sweave and ESS
>>>> support of Sweave is not that sometimes some aspects get confused but
>>>> that it works at all.
>>>>
>>>>> The $ makes Latex-mode use font-latex-math-face (according to M-x
>>>>> describe-text-properties).
>>>>>
>>>>> How to make Latex-mode aware of \Sexpr?
>>>>> Where to look for the Regexp that control highlighting in Latex-mode?
>>>>> Or is there another workaround to be defined in Noweb-mode?
>>>>> I would be happy to learn something about emacs solving this problem!
>>>>>
>>>>> Thanks for your help!
>>>>> Emanuel
>>>>>
>>>>> here is the output of M-x describe-mode in the tex-region of a .Rnw:
>>>>>
>>>>> Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption
>>>>> Column-Number Diff-Auto-Refine File-Name-Shadow
>>>>> Global-Auto-Composition Global-Font-Lock Global-Highlight-Parentheses
>>>>> Highlight-Parentheses Line-Number Noweb Noweb-Font-Lock Reftex
>>>>> Shell-Dirtrack Tooltip Transient-Mark
>>>>>
>>>>> (Information about these minor modes follows the major mode info.)
>>>>>
>>>>> LaTeX mode:
>>>>> Major mode in AUCTeX for editing LaTeX files.
>>>>> ...
>>>>>
>>>>> --
>>>>> Emanuel Heitlinger
>>>>>
>>>>> University of Karlsruhe (IT)
>>>>> Zoological Institute 1 Ecology/Parasitology
>>>>> Kornblumenstr. 13
>>>>> 76131 Karlsruhe
>>>>> Germany
>>>>> Telephone +49 (0)721-608 7654
>>>>>
>>>>> http://www.scienceblogs.de/alles-was-lebt/
>>>>>
>>>>> or
>>>>> University of Edinburgh
>>>>> Institute of Evolutionary Biology
>>>>> Kings Buildings, Ashworth Laboratories, West Mains Road
>>>>> Edinburgh EH9 3JT
>>>>> Scotland, UK
>>>>> Telephone:+44 (0)131-650 6761
>>>>>
>>>>> ______________________________________________
>>>>> ESS-help at stat.math.ethz.ch mailing list
>>>>> https://stat.ethz.ch/mailman/listinfo/ess-help
>>>>>
>>>>
>>>
>>>
>



More information about the ESS-help mailing list