0

There are some old threads asking about getting R to display its graphics in an emacs window (e.g. ESS plot directly to an Emacs buffer?) and the ESS manual says,

11.6.2 Using ESS with windowing devices

Of course, the ideal way to use graphics with ESS is to use a windowing system. Under X Windows, or X11, this requires that the DISPLAY environment variable be appropriately set.

But provides no information on how to do so and my google searches only return results similar to the above references. Can someone direct me to a resource to explain how to set up my ess.el file to use emacs as R's DISPLAY environment?

mikemtnbikes
  • 223
  • 2
  • 9
  • I think you are misunderstanding this. There is no ESS configuration that will make it display graphics in an emacs buffer. It will display them in a window created by your operating system. This shouldn't require any configuration on your part. If this doesn't work, we'll need more info about your system. If you want figures in an Emacs buffer, you'll need to try some of the ideas in the linked question. – Tyler Dec 17 '21 at 16:57
  • Ah.. got it. Do you want to post your comment as an answer so I can accept it? – mikemtnbikes Dec 17 '21 at 18:43
  • @db48x already posted an extended version of this explanation as an answer – Tyler Dec 17 '21 at 18:54

1 Answers1

2

That’s not what that sentence means. Emacs is not an X server. This sentence means that if you have an X server available, and DISPLAY is set to the right value, then R will connect to the X server and open up it’s own GUI windows.

If you are using the Emacs gui, than this is certainly already set up correctly. If you are using Emacs in a terminal emulator, then you can verify that DISPLAY is set in a shell inside that terminal emulator by running echo $DISPLAY. If it is, then Emacs will inherit that setting from the shell and R will inherit it from Emacs, and R will be able to open its own GUI windows. If it isn’t, then you need to consult the documentation for your terminal emulator.

If you really want R to plot things directly into an Emacs buffer, then the usual way to do it is to have R output an image to a file, and then arrange to have the file displayed by Emacs.

db48x
  • 15,741
  • 1
  • 19
  • 23