Skip to content

Help with R on a Mac

6 messages · Benjamin Arthur, Kasper Daniel Hansen, Vincent Vu +3 more

#
Hello,
I am having difficulty getting R to work on my Mac OS X 10.4.6 powerbook G4 
and also with downloading emacs. I have been able to download the R but when 
I double click the icon I get a page with the copyright info and a few 
commands about license and to quit, etc. Executing the 'help.start()' 
command from that screen, opens another window with manuals, reference, etc. 
Could anyone help me to get R working with the partition screen from emacs 
on my computer? Or does the Mac have a better editor that I could use to 
navigate through R. I will most appreciate that. Thanks!
#
From your description it seems to work: you do just not start R with  
Emacs in this fashion. Emacs is - in my opinion - an extremely good  
editor for use with R, because of the way the help system and other  
things interact with Emacs. However, if you have never used Emacs  
before it will also be along hard road - it takes a _long_ time to be  
familiar with Emacs. Rest assured that you will be (very) frustrated  
at times until you suddenly get it :)

Nevertheless, here is an easy walk through to get R and Emacs to work

1) Download R from CRAN. Install it (while you are at it, remember to  
choose "customize" during installation and install g77 and the tcl/tk  
stuff. This will give you R inside your application folder, which you  
can click on to start. Doing so yields a "standard" R editor.

2) Now you need to install Emacs. There are various versions. I use  
"Carbon" Emacs which is a version of Emacs for Mac which is Unix-like  
in its behaviour. There is also AquaEmacs (google it) which is more  
Mac-centric. I choose Carbon Emacs because I want keyboard shortcuts  
etc. to behave in the same way across platforms - I frequently use  
Unix-like systems. Get Carbon Emacs from here
http://homepage.mac.com/zenitani/emacs-e.html
Install it like any other application. Again you get an application  
you start like any other application.

3) Now it is time to get ESS (Emacs speaks statistics) working. This  
is a package for Emacs which makes Emacs works nicely with R (and  
other stuff). Fortunately, Carbon Emacs comes with ESS installed (you  
may have to install it under AquaEmacs). We just need to activate it.  
In order to do so, use a text editor (eg. Text Edit) to open up a file
   ~/.emacs
(~ = your home directory)
This is your Emacs configuration file. In that file you place the  
following line
(require 'ess-site)
You should now be able to start Emacs without any error messages. If  
you get an error message, you have probably mistyped something.

4) Start up Emacs and type
   M-x R
(you do this by holding either the ALT or the APPLE key down while  
you press x. Then you see "M-x" in Emacs. You type R and return.
You should now see R open up inside emacs. Have fun and type a few  
commands.

5) Finally we need to get graphics working. Open up the file
   ~/.profile
and enter the following line
export DISPLAY=:0.0
You should now be able to plot graphics from the inside of Emacs

Further discussion of ESS/Emacs should be directed at the ESS list.

/Kasper
On Apr 15, 2006, at 5:39 PM, Benjamin Arthur wrote:

            
#
I think Kasper means Aquamacs Emacs.  It comes with ESS as well.

http://aquamacs.org/

I would recommend Aquamacs over Carbon emacs.  It is the easy to use  
and the developers have gone out of their way to ensure that the user  
experience is consistent with Mac OS X.  It's a better OS X citizen  
than Carbon Emacs.

To get ESS working on Aquamacs you need to first load the ess package  
with the command:

M-x R-mode (Alt/Option + X, then type R-mode and press enter) will  
start ESS

then M-x R (Alt/Option + X, then type R and press enter) will start R  
inside an emacs buffer.

You'll need to have Darwin X11 running to get proper graphics  
working.  As far as I have experienced with Aquamacs, you don't need  
to play with any configuration files to get it work.

You could also get limited graphics without X11, by using the quartz 
() device.  Due to the way R and Emacs interact, you won't be able to  
interact with these plots.

-Vince
#
Benjamin,
R.

Emacs and ESS is a powerful way to write and run R code. However, given the
nature of your question, you may want to use R.app for your analyses. You
started this application when you double-clicked the R icon. Choose 'New
Document' from the file menu and you have a code window with syntax
highlighting and autocomplete. Apple-return sends any highlighted code to the
R console and all plot code is sent to an aqua window in the OS X-native pdf
format. Be sure to look at the 'R for Mac OS X FAQ' under the Help menu of
R.app

Good luck, Matt
14 days later
#
On 4/30/06, Benilton Carvalho <bcarvalh at jhsph.edu> wrote:
Yes, it does - now that I know to try it.  Thank you.