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

Werner W. pensterfuzzer at yahoo.de
Tue Mar 23 22:25:36 CET 2010


Thanks a lot for the help, Marc and Berry!

I tried hard coding the path to Sweave.sty and also made sure there is no space in the path but still, the \Sexpr did not get translated. I would like to know what flaw there is in my configuration but I tried whatever I could find on the web on \Sexpr problems. 
With the modification of the ESS command to include "SweaveSyntaxNoweb" it does work. I don't know what it does but I am happy that it works! :-)

All the best,
  Wern



----- Ursprüngliche Mail ----
> Von: Charles C. Berry <cberry at tajo.ucsd.edu>
> An: Marc Schwartz <marc_schwartz at me.com>
> CC: Werner W. <pensterfuzzer at yahoo.de>; ess-help at stat.math.ethz.ch
> Gesendet: Dienstag, den 23. März 2010, 20:30:48 Uhr
> Betreff: Re: [ESS] \Sexp{} problem, how to add syntax="SweaveSyntaxNoweb" option to M-n s?
> 
> 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

> You 
> can either manually add the \usepackage{PATH.TO.SWEAVE/Sweave.sty} directive to 
> your .Rnw file's preamble, or see the Details section of ?RweaveLatex for 
> information on other configuration options.
> 
> HTH,
> 
> 
> Marc Schwartz
> 
> 
> ______________________________________________
> 
> 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
> 
> target=_blank >https://stat.ethz.ch/mailman/listinfo/ess-help
> 
> 

Charles C. Berry                
>             (858) 534-2098
      
>                       
>                 Dept of 
> Family/Preventive Medicine
E mailto:
> href="mailto:cberry at tajo.ucsd.edu">cberry at tajo.ucsd.edu    
>             UC San Diego

> href="http://famprevmed.ucsd.edu/faculty/cberry/" target=_blank 
> >http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 
> 92093-0901

______________________________________
über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com



More information about the ESS-help mailing list