[ESS] How can I launch an x-window from emacs ess when running R on a server?x

Erik Iverson eriki at ccbr.umn.edu
Thu Nov 11 07:03:58 CET 2010

On 11/10/2010 11:37 PM, David LeBauer wrote:
> Hello, I am using emacs-snapshot with the ssh.el package, following
> the instructions from the ess manual.
> There are a few ways to open an R session, but this is how I do it:
> 1 open emacs
> 2 C-x C-f /server:dir/file.R this puts me in ESS [S] mode
> 3 Type 'plot(1)'
> 4 C-c C-n to run
> 5 emacs asks for starting directory, and I choose the /server:dir/
> I would like for a figure to pop up but it wont.

You need to enable X forwarding, see below...

> This also doesn't work when using ess-remote in shellor tramp mode,
> but it does work if I set the starting directory to my local desktop.
> Any advice much appreciated. My current workaround is to print the
> file to pdf and then open pdf in DocView mode, but this takes a few
> extra steps and is slow.

You probably won't think it's slow after you use X forwarding :).
Well, for your single point plot it might not be too bad, but it could
get pretty slow if you're making complicated graphics or using ggplot2
for instance.

I've gotten this to work in the past, you simply need to enable
X forwarding when setting up your ssh connection to the remote

I do not know how to enable X forwarding through the tramp method,
but I'm sure it's possible.

I also do not know how to enable X forwarding when using ssh.el,
that could be easy too.

However, just try this. Launch a shell on your local host
(M-x shell),  and do

local% ssh -X remote-server
remote-server% R

Then do M-x ess-remote RET r RET

In R,

 > plot(1)

Depending on your connection, think twice about doc-view
being slow :). One thing with doc-view that you might try
is enabling auto-revert mode for doc-view files.

Good luck!

More information about the ESS-help mailing list