Contents
 
Introduction
To R

Running R in Emacs

A much better way to run R is from within the emacs editor. This adds all sorts of features to make life easier and I strongly recommend it.

If you have never used emacs before, read a short emacs tutorial. If you have but need some quick reference to emacs, take a look at emacs reference card.
 

First Set Up Your .emacs file

We need to add some things to your Emacs startup file so that you can run R from Emacs. Fire up Emacs on your .emacs file:
$ emacs ~/.emacs
and enter the following:
(global-font-lock-mode t)
(load "/home/shimakur/Emacs/ess/lisp/ess-site")
Now quit Emacs (C-x C-c) and start it again. We're all set.
 

Running R

Start up Emacs without a file argument - just type emacs & at the prompt.

Now execute R-mode - enter M-x R Think of M-x as `execute' and `R' for R. Emacs will then ask you for your R Starting Directory - enter the directory where you want to create a new (or open an already existing one) .RData.

This will then produce a new buffer called *R*, which runs R and gives a standard R prompt > - you can now type R expressions at this prompt and they will be run as if you were running from a command window.
 

Emacs Advantages

If you are running R in Emacs you will be able to do some clever things to save you a lot of work. You can use the arrow keys left and right to edit the line you are typing and go back and correct mistakes. You can also use the up and down arrows to recall previous commands, perhaps edit them, and then press Enter to run them.

You'll also get a full log of your session in the buffer. This can be useful when you forget how you did something half an hour ago. The buffer is just like any other Emacs buffer, and can be scrolled around and searched.

To get back to the R prompt from anywhere in Emacs, just do M-> (this is the Emacs code for `end of file').

Other advantages of running in Emacs will become apparent shortly. Now its time to start doing things in R...


Contents