[ESS] Is ess supposed to help with Sweave documents?

Henrik Andersson h.andersson at nioo.knaw.nl
Tue Jan 25 09:51:44 CET 2005


I think this is pretty damn close, yes.

Opening *ESS-errors* I can see the errors.

While looking at the ESS manual (http://ess.r-project.org/ess.pdf) the 
keybinding for ess-parse-errors is C-x ' but the minibuffers says C-c `, 
strange is it not.

Cheers, Henrik


David Whiting wrote:
> On Mon, Jan 24, 2005 at 08:14:52PM +0100, A.J. Rossini wrote:
> 
>>If you are using Sweave using strictly Noweb markup, then the fast and
>>painful way is to use a Makefile to extract the code with noweb and
>>dump it to a file, then reload it.  But you've got to be using markup
>>which is in the intersection of Noweb and Sweave (and I'm not going to
>>go into that argument again).
>>
>>Another option is to use the submit thread command (I don't think it's
>>bound) which creates a temp buffer of the "thread" (i.e. appropriate
>>chunks strung together) and dumps it into a buffer.
> 
> 
> Does this get you nearly there Henrik? If you have a .Rnw file open
> and call this function it will extract the source code (making
> assumptions about markup?), open the source code file and then load
> it. If there is an error you will see the location of the error in the
> *ESS-errors* buffer.  At the moment this function does not
> automatically switch to the buffer on error (and I don't think that I
> will have time to add this just now). But at least you don't need to
> create a Makefile.  You could bind this to a key combination and
> almost use it as simply a C-c C-l.
> 
> 
> (defun ess-R-code-only ()
>   "Extract R source code from a Rnw file and load it."
>   (interactive)
>   (save-excursion
>     ;; Get the name of the file we are working with.
>     (setq namestem (substring (buffer-name) 0 (search ".Rnw" (buffer-name))))
>     (setq R-filename (concat namestem ".R"))
>     ;; Make sure tools is loaded.
>     (setq ess-command (format "library(tools)"))
>     (ess-execute ess-command)
>     ;; Extract the source code.
>     (message "Stangling %S" (buffer-file-name))
>     (setq ess-command (format "Stangle(%S)" (buffer-file-name)))
>     (ess-execute ess-command 'buffer nil nil)
>     ;; Open the source code file.
>     (find-file R-filename)
>     ;; Load the source code into R.
>     (ess-load-file R-filename)))
> 
> 
> Dave
> 


-- 
---------------------------------------------
Henrik Andersson
Netherlands Institute of Ecology -
Centre for Estuarine and Marine Ecology
P.O. Box 140
4400 AC Yerseke
Phone: +31 113 577473
h.andersson at nioo.knaw.nl
http://www.nioo.knaw.nl/ppages/handersson




More information about the ESS-help mailing list