Running R on remote computer via local emacs

[This article was first published on Recipes, scripts and genomics, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Aquamacs in Mac OS X and Emacs in Linux/unix can be used to edit remote (and local) R code and submit pieces of code to a remote R session. For this to work you need to install ess for emacs (Aquamacs comes with ess by default now, I don’t know about emacs). If you don’t have ess, you can install following this recipe.

open an R script using emacs, you can open remote files using TRAMP. You need to do C-x C-f and enter the remote location as “/ssh:[email protected]:/home/username/example.R”. After you opened your remote R script, now you have to start a remote R session. First, we need to ssh to remote host from Emacs/Aquamacs using the following commands.

M-x ssh #after this you need to enter your username, remote host and you will be prompted your password

R #start R
M-x ess-remote #after starting R, you need to start and ess-remote session,
so your R script and R session is connected.

Now you can edit your remote script and also send code to your remote R session from
your script. If you can't ssh from Emacs/Aquamacs you will need to install ssh.el. 
First prepare a .emacs file, put it in your home folder. Also, make .emacs.d folder 
your home directory. You will put the  .el files in this directory.
------contents of .emacs  file -----------

(setq load-path

      (cons "/home/username/.emacs.d" load-path))


(require 'tramp)

(require 'ssh)

(require 'password-cache)

(setq password-cache-expiry nil)

------- end of .emacs file -----------------------

in .emacs.d directory, put the following files

http://www.splode.com/~friedman/software/emacs-lisp/src/ssh.el

or

ftp://ftp.splode.com/pub/users/friedman/emacs-lisp/ssh.el



and this one you need so TRAMP doesn't ask password every time you save a
file

http://braeburn.aquamacs.org/code/master/lisp/password-cache.el

To leave a comment for the author, please follow the link and comment on their blog: Recipes, scripts and genomics.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)