[ESS] \Sexp{} problem, how to add syntax="SweaveSyntaxNoweb" option to M-n s?

Werner W. pensterfuzzer at yahoo.de
Tue Mar 23 23:59:32 CET 2010


Hi Marc,

the R2HTML package was actually the problem. It is embarrassing since now I remember that I have read about it a long time ago and I think even used the option to solve it. I am also using Tinn-R which loads R2HTML by default. 
And you were also right that the solution is in the Sweave FAQ: after adding "options(SweaveSyntax="SweaveSyntaxNoweb")" into a chunk of my .Rnw file, it works!

Thanks again for your help.

Best,
  Wern




----- Ursprüngliche Mail ----
> Von: Marc Schwartz <marc_schwartz at me.com>
> An: Charles C. Berry <cberry at tajo.ucsd.edu>
> CC: ess-help at stat.math.ethz.ch
> Gesendet: Dienstag, den 23. März 2010, 21:31:22 Uhr
> Betreff: Re: [ESS] \Sexp{} problem, how to add syntax="SweaveSyntaxNoweb" option to M-n s?
> 
> 
On Mar 23, 2010, at 3:30 PM, Charles C. Berry wrote:

> On Tue, 23 
> Mar 2010, Marc Schwartz wrote:
> 
>> On Mar 23, 2010, at 7:20 AM, 
> Werner W. wrote:
>> 
>>> Hi,
>>> 
> 
>>> I am currently getting into Emacs & ESS on Windows and it 
> starts to feel like a very nice environment to program in R and Sweave. However, 
> I have a little problem: is it possible to add the option 
> syntax="SweaveSyntaxNoweb" to the issued command when pressing M-n s? Right now 
> I always get an "Undefined control sequence" error from the latex compiler since 
> Sweave is not replacing the \Sexpr{} command at all. I know that this is no 
> problem when I add the above option. I looked at the ess-swv.el file but could 
> figure out how to add an option. It would be great if someone had a hint towards 
> the solution for me.
> 
> 
> I doubt that this solves the 
> problem with \Sexpr{}, but you can copy
> 
> ess-swv-run-in-R into 
> your .emacs file , (possibly) rename it,  and edit the line
> 
> 
>     "local({..od <- getwd(); setwd(%S); %s(%S); 
> setwd(..od) })"
> 
> to add whatever options you want. I use this 
> strategy to force use of the weaver() driver:
> 
>    
>    "local({..od <- getwd(); require(weaver);setwd(%S); 
> %s(%S,driver=weaver()); setwd(..od) })"
> 
> which command I renamed 
> 'ess-swv-run-weaver-in-R'. Then with
> 
> (defun 
> ess-swv-weave-weaver ()
>   "Run Sweave on the current .Rnw 
> file."
>   (interactive)
>   (ess-swv-run-weaver-in-R 
> "Sweave"))
> 
> (define-key noweb-minor-mode-map "\M-n\M-s" 
> 'ess-swv-weave-weaver)
> 
> I can type M-n M-s and force use of the 
> weaver driver
> 
> 
>>> 
>>> Thanks so 
> much,
>>> Wern
>> 
>> 
>> Typically, when 
> the \Sexpr's are not being evaluated, that is being replaced with a scalar, it 
> is an indication that the sweave.sty file is not being found, as it is in that 
> file, that the relevant code is located.
>> 
> 
> 
> Huh?
> 
>> cat("Select a 
> letter:\\Sexpr{sample(letters,1)}\n",file="oneLetter.Rnw")
>> 
> Sweave("oneLetter.Rnw")
> Writing to file oneLetter.tex
> Processing 
> code chunks ...
> 
> You can now run LaTeX on 
> 'oneLetter.tex'
>> readLines("oneLetter.tex")
> [1] "Select a 
> letter:r"
>> 
>> 
> Sweave("oneLetter.Rnw",syntax="SweaveSyntaxNoweb")
> Writing to file 
> oneLetter.tex
> Processing code chunks ...
> 
> You can now 
> run LaTeX on 'oneLetter.tex'
>> readLines("oneLetter.tex")
> [1] 
> "Select a letter:g"
>> 
> 
> \Sexpr{} inserts the result 
> into the tex file with either the default options or 
> syntax="SweaveSyntaxNoweb"
> 
> And I get a similar result when I 
> open oneLetter.Rnw with emacs and type M-n s.
> 
> Does Sweave.sty 
> really figure into this??
> 
> HTH,
> 
> 
> Chuck


Chuck,

I may very well be wrong and I was going from 
> perhaps faulty memory from some time ago. There was a period of time when I was 
> still on Fedora and I believe, after a clean version upgrade, I was having 
> problems with .Rnw files, where the \Sexpr's were not being processed. 
> 

That being said, I cannot now (on OSX) replicate the problem, so unless 
> something has changed in the intervening time frame, my memory may be 
> faulty.

The only other conflict that I know of is if the R2HTML package 
> gets loaded, which is in the Sweave FAQ. That was not my issue in the past, as I 
> have not used that package. So I am still at a loss to explain the prior 
> behavior or apparently, correctly recall the 
> fix.

Thanks,

Marc

______________________________________________

> ymailto="mailto:ESS-help at stat.math.ethz.ch" 
> href="mailto:ESS-help at stat.math.ethz.ch">ESS-help at stat.math.ethz.ch mailing 
> list

> >https://stat.ethz.ch/mailman/listinfo/ess-help

__________________________________________________
Do Y
agenden Schutz gegen Massenmails. 
http://mail.yahoo.com



More information about the ESS-help mailing list