[ESS] remote R via ssh - customizing the command used to start R

Chris Wallace chris.wallace at cimr.cam.ac.uk
Mon Jan 4 15:49:16 CET 2016


Thanks to a suggestion from Stephen Eglen, I have the following solution.

On serverB, create a file ~/bin/R.magic with the contents

#!/bin/bash
module load R/3.2.3 && R

In my local .emacs, define the function

(defun RserverB ()
   "Run R on serverA using the R.magic script"
   (interactive)
   (setq inferior-R-program-name "/home/USER/bin/R.magic")
   (setq ess-directory "/ssh:USER at serverB:~/")
   (R))

Now `M-x R` will work as before, and `M-x RserverB` will run R.magic on 
serverB.

Note that it was not sufficient to just (setq inferior-R-program-name 
"R.magic") as my PATH doesn't appear to be set when tramp opens the 
connection to serverB.

Thanks Stephen!

Chris


On 04/01/16 12:34, Chris Wallace wrote:
> Dear ESS-help,
>
> I usually run R on a remote server ("serverA") via tramp:
>
> M-x R
>
> and then I reply to the prompt asking for a starting directory by
>
> /ssh:user at serverA:~/
>
> and all has been well.  Now, I need to run R on a different server 
> ("serverB") and there I need to run a command before `R` so that the 
> right R is found.  Specifically, I need to run `module load R/3.2.3 && 
> R`.  I can do so using `M-x shell` and then ssh to serverB, load the 
> module, and start R.  But I miss some of the functionality with `M-x R`.
>
> I figure everything in ESS is configurable, so I tried to customize 
> inferior-R-program-name to "module load R/3.2.3 && R" but that failed 
> with
>
> env: module load R/3.2.3 && R: No such file or directory
>
> And, besides, I need to load this module only on serverB, not server A 
> (which doesn't have the module command at all).
>
> So, where should I look to customize the command used to start R on a 
> specific remote server?
>
> Thanks, Chris
>
>
>


-- 
JDRF/WT Diabetes & Inflammation Laboratory (DIL),
NIHR Cambridge Biomedical Research Centre,
Cambridge Institute for Medical Research,
University of Cambridge

Website: http://chr1swallace.github.io
DIL Website: http://www-gene.cimr.cam.ac.uk



More information about the ESS-help mailing list