[macemacsjp-english 585] Re: graphical windows using ESS and R

Back to archive index

Kasper Daniel Hansen khans****@stat*****
Tue Jun 13 08:13:40 JST 2006


Hi Nick

On the Mac you have two screen plotting devices: the X11 interface  
and the Aqua interface. I assume you are interested in getting X11 to  
work. For that to happen you need to
   1) Install and start the X11 server from the development tools
   2) Make sure your DISPLAY variable is set
Since you can do everything in a terminal I assume that X11 is  
installed and started. You now need to make the R runing inside  
Carbon Emacs aware of your display setting. One way to make sure that  
it works is doing
  R> Sys.putenv(DISPLAY = ":0.0")
this sets the environment variable from inside of R. You can check  
what the current value is by doing \
  R> Sys.getenv("DISPLAY")
The reason why you get a Rplot.ps file is that R at startup does not  
detect X11 and then it uses the postscript device as the default  
device (the plot command writes to the default device per ....  
default :)

If you want a more permanent solution (and you do) you can put it  
inside ~/.profile so that this file contains the following line
   export DISPLAY=:0.0
You may have to log out and back in again for this to work. The  
advantage of putting it in .profile is that it will work for other  
applications too. Another way, which is R specific, is to put the  
command above inside an R configuration file. There are several  
choices (~/.Renviron, ~/.Rprofile) , but some of them will not work  
if you need to run R in BATCH mode. I suggest you go the .profile  
route. The reason why it works under the terminal is probably because  
you have some display setting which is not being detected outside the  
terminal (note again, that you may have to log out and log in again  
fro this to work).

As you can guess, I am using R under ESS without any problems. Please  
get back if the above does not help. In that case, please post the  
results of Sys.getenv("DISPLAY") from both the terminal version of  
ESS and the Carbon Emacs version.

/Kasper



On Jun 12, 2006, at 8:15 AM, Nick Reich wrote:

> Hello,
>
> I am using R (the statistical software) with this Emacs package and
> am trying to have graphical windows pop-up as I work in my
> interactive session with R.  For example, I'd like to type "plot(rnorm
> (50))" and have the little R plot of these fifty observations from a
> normal distribution be displayed in a new graphical window.  This is
> possible when running emacs in a terminal-type environment.  Is is
> possible using this installation of Emacs?
>
> As it is, any plots generated by commands that I type are sent by
> default to a file called Rplots.ps in the working directory.  But for
> an interactive session, this is not so useful.
>
> Is there a way to coerce these graphics to open up in this or another
> application?
>
> Thanks,
> Nick
> _______________________________________________
> macemacsjp-english mailing list
> macem****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/macemacsjp-english




More information about the macemacsjp-english mailing list
Back to archive index