[ESS] request for comments: completion within .R buffers

Stephen Eglen S.J.Eglen at damtp.cam.ac.uk
Tue Jun 22 15:19:47 CEST 2010

Simon Jackman <jackman at stanford.edu> wrote:

> May I add one more request?
> I frequently find myself "tweeking" a graph, getting it ready for a slide or a
> paper etc.  This usually involves re-running non-trivial chunks of R after
> various edits etc.
> Could there be a cousin to eval-function that looked backwards for a "pdf(…)"
> command [or jpeg etc, a command that opens a graphics device] and then forward
> to a "dev.off()", and then executed the R command in the enclosed region?

I know exactly what you mean, when making figures.

My solution is normally to put all the code that makes a plot into one

something like

my.pic <- function() {



and then call my.pic() 

( on.exit(...) is nice as it will close the figure, even if your code in
"stuff" errors..)

However, for your approach, you could try marking (C-SPC and current
point) the region you want and then doing C-x n n (narrow-to-region).
Then C-c C-b will send the whole buffer, which at this time is just your
code to make the plot.  C-x n w does the "widen" command to remove

This approach is more general and does not rely on any code to find
pdf() etc.


More information about the ESS-help mailing list