helpdesk@stat.rice.edu
ESS (Emacs Speaks Statistics) is an Emacs extension. It is designed to make S-Plus/R easier to use, especially on Unix platforms. This guide will lead you through some of the most useful ESS features.
ESS is installed under helpdesk. To make use of ESS, you need to add the following line to your .emacs file in /home/username/ folder:
(load "/home/helpdesk/trial/ess/ess-site")ESS provides 50+ functions which are bound to keys like C-c C-f. Since these key-bindings are not easy enough to remember, we have bound some of the most important functions to F1, F9, F10, F11, F12. If you would like to use these bindings, download the sample .emacs file (created by Blair Christian) from http://www.stat.rice.edu/ helpdesk/dotfiles/.emacs.blair to your /home/username folder. You can use wget url command, where url is the url location of the file. Throughout this guide, I will use these bindings, instead of the standard ones.
If ESS is properly installed, emacs will open a buffer named *R* and start an instance of R in it. If emacs returns an error, check your .emacs file. The easiest way to correct your .emacs problem is to use the sample .emacs file. You can copy the sample .emacs file directly from the helpdesk if you are on stat007, just use command:
cp /home/helpdesk/download/ess.emacs ~/.emacs
Enter
vector1 <- c(1,2,3)<CR>Now, you would like to enter another command:
vector2 <- c(3,3,3)<CR>You have several ways to input the second command. Instead of inputing the whole command again, you can use one of the following features of ESS:
If you use gnome, Ctrl-Arrow keys are intercepted by gnome to do something else. In this case, try Alt-Up/Down.
Then, you want to add the two vectors together, using command:
vector <- vector1 + vector2The shortest key sequence is:
ve<tab>_ve<tab>1 + ve<tab>2Here we used two features of ESS:
Unfortunately, S-Plus 6.0 for Sun Solaris (the version we are using) has a bug which prevents ESS from getting the right completion list. I have sent a bug report to ESS and newer version of ESS (or S-Plus) is supposed to solve or work around this problem.
Now, try to input more commands... Here is more tricks:
Files with extension .r .ssc or .s will be opened in ESS/S mode. You can tell this be the ESS[S] string on the status line. Press
C-x C-f test.rto open file test.r. If this file does not exist, a new file will be created.
Input the following commands
vector1 <- c(2,3,4)You can not use completion here but you have all the editing capacity of emacs at hand. The best part of the ESS/S mode is the syntax coloring. With the help of colors, the program is easier to read and it is easy to pick out minor grammar mistakes like unbalanced )'s .
vector2 <- c(3,3,3)
vector <- vector1 + vector2
Put the cursor on the first line, make sure you have a R process running. press
F9ESS will ask you which process to load, if you only have one S-Plus/R process, press enter. ESS will then send the current line to the R process and execute. The actual ESS command is ess-eval-line-and-step. It is possible to use other commands like ess-eval-line-and-go, ess-eval-line. The first command evaluate the current line and go to the command window, the second command just execute the current line. If you would like to see all ess comand, type
M-x ess-<tab>Similarly, use F10 to send selected text and F11 to send the whole buffer to the S-Plus/R process. So you have your choice of stepping through, evaluating part of the script or source the whole buffer.
F1 and F12 keep their meaning as they do in command window.
The windows version of S-Plus is fairly easy to use but the windows version of R is not. As a result, you might want to install the windows version of R, Emacs and ESS. An outline of the steps is:
helpdesk
$Date: 2003/08/12 04:51:00 $
This document was generated using the LaTeX2HTML translator Version 2002-1 (1.68)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -local_icons -no_subdir -split 0 ess.tex
The translation was initiated by Statistics Helpdesk on 2003-08-15