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 27.3 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 27.3.

Figure 27.3: 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.
Image 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-2010 Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
The PDF version is a formatted comprehensive draft book (with over 800 pages).
Brought to you by Togaware. This page generated: Sunday, 22 August 2010