How can I background the R process in ESS / Emacs? How can I background the R process in ESS / Emacs? r r

How can I background the R process in ESS / Emacs?


ESS runs R as asynchronous process. You don't need to background anything. You can run your code for hours and still work in ESS uninterrupted.

Your problem seems to be something else. When you execute your script you do it "visibly", i.e. your executed code is printed to the terminal. This cause Emacs to freeze.

Set ess-eval-visibly to nil and huge chunks of code will be sent to R instantly:

(setq ess-eval-visibly nil)

Cheers.

[update]

There is a new setting for ess-eval-visibply in recent versions of ESS - 'nowait. It places your code in an inferior buffer and then sends it to the subprocess. In this way you can see your code and all the output afterwards without waiting for the subprocess to finish.

[/update]


M-x R will start an R session (the default buffer name is *R*). If your press M-x R again, a second R session will be started (with buffer name *R:2*).

Each session has its own R process, so you can run a long R script in one and still use the other independently.

Pressing C-x C-b brings up the buffer list, which would allow you to switch between R sessions.

Or, if you put

(global-set-key "\C-cr" 'ess-request-a-process)

in your .emacs initialization file, then every time you press C-c r you will be prompted for which R session (buffer) you wish to switch to. If you only have one session, it will switch there automatically.


In my personal experience, ESS isn't very good at handling very large scripts, in that at times the rest of Emacs becomes unusable. Perhaps you are better off doing development in ESS, then running the full script in BATCH mode.