Togaware DATA MINING
Desktop Survival Guide
by Graham Williams
Google

Emacs and ESS

We discussed above the philosophy of using an editor to interact with R, and thus fortuitously saving our work to file. Numerous editor based interfaces are available for R, and a good choice is Emacs with the ESS package.

Emacs, as often it does, provides the most sophisticated access to R, through the use of the ESS Emacs package, providing a simple mechanism to type R commands into a file and have them executed by R on request. Figure [*] illustrates the basic interface. After starting Emacs, load in a file (or create a new file) with a name ending in R. With the ESS package for Emacs installed (for example, installing the ess package on Debian GNU/Linux) you will see an empty window with an R toolbar, similar to Figure [*].

Figure: The ESS GUI interface to R within Emacs, showing the edit window on top, where R code can be constructed and saved to file and requested to be evaluated. The R window below is where the R code is evaluated and its output is displayed.
[width=0.8]emacs-ess

Initiate an R subprocess in Emacs by clicking on the R icon. You'll be asked for a folder for R to treat as it's default location for storing and reading data. A buffer named *R* will display and you can type R functions directly to have them evaluated. Switching back to an R file buffer (or, as in the figure, splitting the window to display both buffers) will allow you to type R functions into the buffer and have them evaluated on request. The series of icons to the right of the R and SPlus icons allow the functions in the file buffer to be executed in the R subprocess buffer. From left to right they are: evaluate the current line (the arrow and single line); evaluate the currently highlighted region; load the file into R; or evaluate the current function. Simply clicking one of these icons will cause the R commands to be evaluated. It is a simple yet effective interface.

Copyright © 2004-2006 Graham.Williams@togaware.com
Support further development through the purchase of the PDF version of the book.
Brought to you by Togaware.