Desktop Survival Guide
by Graham Williams
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 .
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 [email protected] Support further development through the purchase of the PDF version of the book.