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 we introduce here one of the better options: 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 1.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 1.3.

Figure 1.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 the R window below where the R code is evaluated.
Image emacs-ess

If you have not already done so, initiate an R subprocess 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. An R buffer will then display, into which you could type R commands to have then evaluated. Go back to the file buffer (or, as in the figure, split the window to display both buffers) and type a few simple commands into the buffer. The series of icons to the right of the R and SPlus icons allow the commands 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-2005
Brought to you by Togaware.