I don’t know how, but somehow, I stumbled on how to run a remote R session in emacs.
Since Spring 2006 I’ve always used emacs with ESS to run R (did it on windows, switched to linux for years, and most recently, on my macbook). I liked this workflow because I get the same usual interface across multiple platforms. Plus, I use emacs for everything computery or scientific, like using coding Python or C.
Regarding the same interface across multiple platforms, I use, for example, emacs + ESS + R whenever I remotely log into the remote servers dedicated to computing. I just need to ssh into the server, fire up emacs and fire up R. However, I almost always write all of my code on the local computer, and when I’m ready to run the final code, I either run it as a batch script (utlizing
screen (to keep the session runnning after I log out, see my post on R with unix tools), or through emacs. These days, I’ve been doing it with
screen mainly so disconnects to the server won’t interrupt my script.
I just found yet another way to do this: write code on my local computer and then send code to a remote R session in my local emacs. I ran into this by googling ‘emacs ess multiple R session’. Instructions are described here (section 3.3: ESS on remote computers). We need this file for things to work. This site clarified how to get graphics to work.
Instructions as follow:
- Download the
- Install it the usual way or place it in
~/.emacs.d. In your emacs init file, add:
<pre class="src src-sh">;; add path to emacs
;; http://edward.oconnor.cx/2005/09/installing-elisp-files (add-to-list ‘load-path “~/elisp”)
;; load ssh.el file from elisp ;; this is to run ESS remotely on another computer in my own emacs, or just plai n old reading remote files ;; (require ‘ssh)
- Fire up emacs. Type ‘M-x ssh’. For the host settings, do something like ‘-X -C email@example.com’ (X is for X windows forwarding, C is for compression of graphics, so plots can be displayed faster). Type in password.
- You wil be logged into a shell session on your server. Fire up R by typing R then enter. R is now running in an emacs buffer. Type
M-x ess-remote. For dialect, select
- Open up any
.Rfile on your computer, and use the usual keyboard shortcuts to send code to the remote R session.
W can also achieve the same results without the
ssh.el file. In emacs, type
M-x shell. In the shell buffer, ssh into the server and then run R. Type
M-x ess-remote and everything should still work.
Next thing to get working is to open remote files in my local emacs.