ESS version 5.7.1
by A.J. Rossini, R.M. Heiberger, K. Hornik, M. Maechler, R.A. Sparapani and S.J. Eglen.
Emacs Speaks Statistics (ESS) provides an intelligent, consistent interface between the user and the software. ESS interfaces with SAS, S-PLUS, R, BUGS/JAGS and other statistical analysis packages under the Unix, Microsoft Windows, and Apple Mac operating systems. ESS is itself a package within the emacs text editor and uses emacs features to streamline the creation and use of statistical software. ESS knows the syntax and grammar of statistical analysis packages and provides consistent display and editing features based on that knowledge. ESS assists in interactive and batch execution of statements written in these statistical analysis languages.
The S family (S, Splus and R) and SAS statistical analysis packages provide sophisticated statistical and graphical routines for manipulating data. Emacs Speaks Statistics (ESS) is based on the merger of two pre-cursors, S-mode and SAS-mode, which provided support for the S family and SAS respectively. Later on, Stata-mode was also incorporated.
ESS provides a common, generic, and useful interface, through emacs, to many statistical packages. It currently supports the S family, SAS, BUGS/JAGS, Stata and XLisp-Stat with the level of support roughly in that order.
A bit of notation before we begin. emacs refers to both
GNU Emacs by the Free Software Foundation, as well as
XEmacs by the XEmacs Project. The emacs major
mode ESS[language]
, where language
can take values such as
S
, SAS
, or XLS
. The inferior process interface
(the connection between emacs and the running process) referred to as inferior ESS
(iESS
), is denoted in the modeline by ESS[dialect]
, where
dialect
can take values such as S3
, S4
, S+3
,
S+4
, S+5
, S+6
, S+7
, R
, XLS
, VST
, SAS
.
Currently, the documentation contains many references to `S' where actually any supported (statistics) language is meant, i.e., `S' could also mean `XLisp-Stat' or `SAS'.
For exclusively interactive users of S, ESS provides a number of features to make life easier. There is an easy to use command history mechanism, including a quick prefix-search history. To reduce typing, command-line completion is provided for all S objects and “hot keys” are provided for common S function calls. Help files are easily accessible, and a paging mechanism is provided to view them. Finally, an incidental (but very useful) side-effect of ESS is that a transcript of your session is kept for later saving or editing.
No special knowledge of Emacs is necessary when using S interactively under ESS.
For those that use S in the typical edit–test–revise cycle when programming S functions, ESS provides for editing of S functions in Emacs edit buffers. Unlike the typical use of S where the editor is restarted every time an object is edited, ESS uses the current Emacs session for editing. In practical terms, this means that you can edit more than one function at once, and that the ESS process is still available for use while editing. Error checking is performed on functions loaded back into S, and a mechanism to jump directly to the error is provided. ESS also provides for maintaining text versions of your S functions in specified source directories.
Statistical packages are powerful software systems for manipulating and analyzing data, but their user interfaces often leave something something to be desired: they offer weak editor functionality and they differ among themselves so markedly that you have to re-learn how to do those things for each package. ESS is a package which is designed to make editing and interacting with statistical packages more uniform, user-friendly and give you the power of emacs as well.
ESS provides several features which make it easier to interact with the ESS process (a connection between your buffer and the statistical package which is waiting for you to input commands). These include:
tcsh
's facility for filenames; here it
also applies to object names and list components.
See Completion.
objects()
and search()
.
See Hot keys.
If you commonly create or modify S functions, you will have found the standard facilities for this (the ‘fix()’ function, for example) severely limiting. Using S's standard features, one can only edit one function at a time, and you can't continue to use S while editing. ESS corrects these problems by introducing the following features:
Finally, ESS provides features for re-submitting commands from saved transcript files, including:
Changes/New Features in 5.6:
Changes/New Features in 5.4:
make-regexp
to regexp-opt
for font-locking is
complete. The new regexp-opt
is now the default since
it is better than the old code in many ways (and especially more
maintainable). However, there are certainly some special
cases missed (bug reports and patches welcome!).
Setting ess-sas-run-regexp-opt
to nil
will result
in the old code being used.
=
now results in
<-
.
(ess-r-args-show)
now
uses the new (tooltip-show-at-point)
contributed by Erik Iverson.
ess-change-directory
for setting both
emacs' current directory and the directory of an *R* or *S* buffer.
Changes/New Features in 5.3.11:
Changes/New Features in 5.3.10:
Changes/New Features in 5.3.9:
*R*
) and transcript modes no longer
fontify language keywords (such as for
, in
, etc).
ess-sta-delimiter-friendly
setting
to t
to convert embedded semi-colons to newlines for Stata processing.
ess-mode
and noweb-mode
.
M-x comment-region
now available!
ess-swv-*
commands (and keybindings) are now in
a submenu of the “Noweb” menu, when editing Sweave files.
Changes/New Features in 5.3.8:
ess-sas-submit-command
and
ess-sas-submit-command-options
now recognized by ess-sas-submit-region
ess-r-args-auto-show
).
ess-eval-function-or-paragraph-and-step
).
system
command in version 1.0.3; specify whether
this command is available via ess-jags-system
; if not
present, then no links are created so that the *shell*
buffer does not become unresponsive during the batch run
Changes/New Features in 5.3.7:
ess-default-style
now *is* customizable, i.e.,
changing its value in ~/.emacs now does have the desired effect.
ess-font-lock-mode
is a new variable (default: t)
which controls whether font-locking is enabled in ESS buffers.
ess-sas-submit-command-options
which is buffer-local; portable
snooze for MS Windows via customize-able ess-sleep-for
(floats welcome);
Xpdf now supported as a PDF viewer
ess-continued-statement-p
for R and S.
Rgui
on MS Windows to send lines directly from emacs
to Rgui
is available in file lisp/essd-rgui.el
.
Preliminary documentation is in file doc/rgui-doc.txt
.
Changes/New Features in 5.3.6:
Changes/New Features in 5.3.5:
R-mode
which is active by default and can be customized via
ess-r-args-electric-paren
; i.e., use (setq
ess-r-args-electric-paren nil)
to turn it off. Further,
ess-r-args-show-as
allows to switch to the “tooltip” mode.
ess-get-pdf-viewer
and *-ps-viewer; built on new
customizable variables ess-pdf-viewer-pref
and
ess-ps-viewer-pref
; currently used in ess-swv-PDF
and
*-PS
.
ess-swv-PDF
to run pdf viewer only if
pdflatex was ok
ess-swv-weave
to start R automatically if
none is running.
Changes/New Features in 5.3.4:
Changes/New Features in 5.3.3:
ess-display-buffer-reuse-frames
set to true (which changes default behavior) such that execution or
help *frames* are reused.
Changes/New Features in 5.3.2:
(require 'essd-bugs)
with ESS[BUGS]
and JAGS by (require 'essd-jags)
with ESS[JAGS]. But, only one
of them can be used at a time since they don't play nice together. Also,
C-c C-c is now bound to the function ess-bugs-next-action
(F12 has been retired). And finally, note that essl-bug.el
is deprecated and the replacement is essl-bugs.el.
Changes/New Features in 5.3.1:
make install
ess-assign-key
is now C-x =.
RSiteSearch(..)
but with the advantage of
using Emacs' preferred browser, see browse-url-browser-function
Changes/New Features in 5.3.0:
ess-use-inferior-program-name-in-buffer-name
,
which enables using the executable name instead of the dialect name for
R. Feature request.
ess-eval-paragraph-and-step
and
ess-eval-function-or-paragraph-and-step
are bound to keys
C-c C-p and C-c C-c respectively and to the menu in
ESS-mode; also bound in the help mode (for evaluating examples).
ess-toggle-S-assign-key
allows to
assign the “ <- ” insertion to an arbitrary key.
comment-dwim
may be broken, if so, use M-x comment-region and M-x
uncomment-region instead; only valid PROCs are fontified which is very
helpful finding syntax errors (currently supported: BASE, ETS, FSP, GRAPH,
IML, INSIGHT and STAT); the “feature” where F-keys take you to an
empty buffer when the requested destination is a file that does not exist
has been fixed, now the request results in a no-op.
Further, sas-mode now also works in simple terminals.
Changes/New Features in 5.2.11:
ess-sas-file-root
for details; all lag
and dif
functions now fontified correctly
ess-s-versions
and
ess-s-versions-list
, are used to tell ESS what other versions of
Splus you would like to run.
Changes/New Features in 5.2.10:
make install
Changes/New Features in 5.2.9:
ess-beginning-of-function
) etc now work for many more
cases, including S4 method definitions.
options("help.try.all.packages" =
TRUE)
then ?rlm
will list which packages rlm is defined in. This help
buffer is not bogus, but instead is now relabelled “*help[R](rlm in
packages)*”.
Changes/New Features in 5.2.8:
Changes/New Features in 5.2.7:
Changes/New Features in 5.2.6:
Changes/New Features in 5.2.5:
(ess-cleanup)
, called from
ess-quit, now depends on the new customizable variable
ess-S-quit-kill-buffers-p
which defaults to nil
.
Consequently, the question “Delete all buffers associated
with ..?” will not be asked anymore by default.
recode
application as well which is available on many platforms
Changes/New Features in 5.2.4:
dd
command (only available on unix or unix-like platforms).
ess-create-object-name-db
) since modern computers seem fast
enough for dynamic completion. (We expect few users, if any, have
been using the pre-computed database method.)
Changes/New Features in 5.2.3:
Changes/New Features in 5.2.2:
Changes/New Features in 5.2.1:
Changes/New Features in 5.2.0:
Changes/New Features in 5.1.24:
Changes/New Features in 5.1.23:
Changes/New Features in 5.1.22:
Changes/New Features in 5.1.21:
Changes/New Features in 5.1.20:
Changes/New Features in 5.1.19:
Changes/New Features in 5.1.18:
Changes/New Features in 5.1.17:
Changes/New Features in 5.1.16:
Changes/New Features in 5.1.15:
Changes/New Features in 5.1.14:
Changes/New Features in 5.1.13:
Changes/New Features in 5.1.12:
Changes/New Features in 5.1.11:
Changes/New Features in 5.1.10:
Changes/New Features in 5.1.9:
Changes/New Features in 5.1.8:
Changes/New Features in 5.1.2:
The ESS environment is built on the open-source projects of many contributors, dating back to 1989 where Doug Bates and Ed Kademan wrote S-mode to edit S and Splus files in GNU Emacs. Frank Ritter and Mike Meyer added features, creating version 2. Meyer and David Smith made further contributions, creating version 3. For version 4, David Smith provided significant enhancements to allow for powerful process interaction.
John Sall wrote GNU Emacs macros for SAS source code around 1990. Tom Cook added functions to submit jobs, review listing and log files, and produce basic views of a dataset, thus creating a SAS-mode which was distributed in 1994.
In 1994, A.J. Rossini extended S-mode to support XEmacs. Together with extensions written by Martin Maechler, this became version 4.7 and supported S, Splus, and R. In 1995, Rossini extended SAS-mode to work with XEmacs.
In 1997, Rossini merged S-mode and SAS-mode into a single Emacs package for statistical programming; the product of this marriage was called ESS version 5. Richard M. Heiberger designed the inferior mode for interactive SAS and SAS-mode was further integrated into ESS. Thomas Lumley's Stata mode, written around 1996, was also folded into ESS. More changes were made to support additional statistical languages, particularly XLispStat.
ESS initially worked only with Unix statistics packages that used standard-input and standard-output for both the command-line interface and batch processing. ESS could not communicate with statistical packages that did not use this protocol. This changed in 1998 when Brian Ripley demonstrated use of the Windows Dynamic Data Exchange (DDE) protocol with ESS. Heiberger then used DDE to provide interactive interfaces for Windows versions of Splus. In 1999, Rodney A. Sparapani and Heiberger implemented SAS batch for ESS relying on files, rather than standard-input/standard-output, for Unix, Windows and Mac. In 2001, Sparapani added BUGS batch file processing to ESS for Unix and Windows.
ess-eval-line-and-next-line
are by Rod Ball.
ESS version 5 is being developed and currently maintained by
The latest released version of ESS is always available on the web at: ESS web page or StatLib
The latest development version of ESS is available via https://svn.R-project.org/ESS/, the ESS Subversion repository. If you have a Subversion client (see http://subversion.tigris.org/), you can download the sources using:
% svn checkout https://svn.r-project.org/ESS/trunk path
which will put the ESS files into directory path. Later, within that directory, `svn update' will bring that directory up to date. Windows-based tools such as TortoiseSVN are also available for downloading the files. Alternatively, you can browse the sources with a web browser at: ESS SVN site. However, please use a subversion client instead to minimize the load when retrieving.
If you remove other versions of ESS from your emacs load-path, you can then use the development version by adding the following to .emacs:
(load "/path/to/ess-svn/lisp/ess-site.el")
Note that https is required, and that the SSL certificate for the Subversion server of the R project is
Certificate information: - Hostname: svn.r-project.org - Valid: from Jul 16 08:10:01 2004 GMT until Jul 14 08:10:01 2014 GMT - Issuer: Department of Mathematics, ETH Zurich, Zurich, Switzerland, CH - Fingerprint: c9:5d:eb:f9:f2:56:d1:04:ba:44:61:f8:64:6b:d9:33:3f:93:6e:ad
(currently, there is no “trusted certificate”). You can accept this certificate permanently and will not be asked about it anymore.
If you need to install ESS, read Installation for details on what needs to be done before proceeding to the next chapter.
In this manual we use the standard notation for describing the keystrokes used to invoke certain commands. C-<chr> means hold the CONTROL key while typing the character <chr>. M-<chr> means hold the META or EDIT or ALT key down while typing <chr>. If there is no META, EDIT or ALT key, instead press and release the ESC key and then type <chr>.
All ESS commands can be invoked by typing M-x command. Most of the useful commands are bound to keystrokes for ease of use. Also, the most popular commands are also available through the emacs menubar, and finally, if available, a small subset are provided on the toolbar. Where possible, keybindings are similar to other modes in emacs to strive for a consistent user interface within emacs, regardless of the details of which programming language is being edited, or process being run.
Some commands, such as M-x R can accept an optional `prefix' argument. To specify the prefix argument, you would type C-u before giving the command. e.g. If you type C-u M-x R, you will be asked for command line options that you wish to invoke the R process with.
Emacs is often referred to as a `self-documenting' text editor. This applies to ESS in two ways. First, limited documentation about each ESS command can be obtained by typing C-h f. For example, if you type C-h f ess-eval-region, documentation for that command will appear in a separate *Help* buffer. Second, a complete list of keybindings that are available in each ESS mode and brief description of that mode is available by typing C-h m within an ESS buffer.
Emacs is a versatile editor written in both C and lisp; ESS is written in the Emacs lisp dialect (termed `elisp') and thus benefits from the flexible nature of lisp. In particular, many aspects of ESS behaviour can be changed by suitable customization of lisp variables. This manual mentions some of the most frequent variables. A full list of them however is available by using the Custom facility within emacs. (Type M-x customize-group RET ess RET to get started.) Customization provides details of common user variables you can change to customize ESS to your taste, but it is recommended that you defer this section until you are more familiar with ESS.
The following section details those steps necessary to get ESS running on your system.
For a Unix or Unix-like installation, please follow the next steps. Retrieve the latest tgz file (ess-VERSION.tgz) from ESS downloads area.
GNU Emacs Simple Instructions: for recent versions of Emacs (22.x or higher) and ESS, the installation process is simple.
%prompt gtar zxf ess-VERSION.tgz # for GNU tar %prompt gunzip < ess-VERSION.tgz | tar xf - # for Unix tar
(require 'ess-site)
to ~/.emacs and restart Emacs.
(load "~/ess/ess-VERSION/lisp/ess-site")
in ~/.emacs and restart Emacs.
XEmacs Simple Instructions: for recent versions of XEmacs (21.x or higher) and ESS, the installation process is simple.
%prompt gtar zxf ess-VERSION.tgz # for GNU tar %prompt gunzip < ess-VERSION.tgz | tar xf - # for Unix tar
(require 'ess-site)
to ~/.xemacs/init.el and restart XEmacs.
(load "~/ess/ess-VERSION/lisp/ess-site")
in ~/.xemacs/init.el and restart XEmacs.
Edit the default locations of LISPDIR
, INFODIR
and
ETCDIR
in Section 1 of Makeconf (if you are
using XEmacs, then edit the XEmacs subsection in Section 1).
You can compile those files by:
make all
When that completes successfully, install the compiled files:
make install
For Microsoft Windows installation, please follow the next steps. Retrieve the latest zip file (ess-VERSION.zip) from ESS downloads area.
GNU Emacs Simple Instructions: for recent versions of Emacs (22.x or higher) and ESS, the installation process is simple.
(require 'ess-site)
to ~/.emacs and restart Emacs.
(load "C:/ess/ess-VERSION/lisp/ess-site")
in ~/.emacs and restart Emacs.
XEmacs Simple Instructions: for recent versions of XEmacs (21.x or higher), the installation process is much simpler. Hopefully, these simple instructions will work for you. If not, then more detailed, manual instructions follow.
HOME
environment variable to be defined. You can
create it by visiting the following dialog:
My Computer->Control Panel->System->Advanced->Environment Variables
In the User variables window, press New. And create a variable
named HOME
with a value something like (you must
use forward slashes /
rather than backslashes \
)
c:/Documents and Settings/%USERNAME%/Application Data
. Then press OK for that
window and press OK for the main window. If you also have GNU Emacs
installed, GNU Emacs will recognize HOME
and expand ~
accordingly.
C-x C-f
followed by a ~
.
From the Subdir menu, select Create Directory, and enter .xemacs
(require 'ess-site)
to ~/.xemacs/init.el and restart XEmacs.
(load "C:/ess/ess-VERSION/lisp/ess-site")
in ~/.xemacs/init.el and restart XEmacs.
Now, you should be ready to use ESS. For example, to edit statistical programs, load the files with the requisite extensions (".sas" for SAS, ".S" or "s" or "q" or "Q" for S-PLUS, ".r" or ".R" for R, and ".lsp" for XLispStat). One further step is needed if you wish to run statistical processes, see below.
To run statistical processes under ESS, Windows users will need to make sure that the directories for the software they will be using is in the PATH environment variable.
On Windows NT/2000/XP, add the directories to the PATH using the
My Computer->Control Panel->System->Advanced->Environment Variables
menu.
Note that the directory containing the program is
added to the PATH, not the program itself. One such line is needed
for each software program. Be sure to use the abbreviation
progra~1
and not the long version with embedded blanks as
this may cause problems. Also, make sure to use backslashes \
since Windows requires them.
An alternative, for R users, is that rather than adjusting the PATH variable, you can add the following to your emacs initialization file (and restart emacs):
(setq inferior-R-program-name "c:/progra~1/R/R-2.2.1/bin/Rterm.exe")
This assumes that you have installed R-2.2.1 in the default location. Change the path otherwise to point to other locations.
Windows users who place S-PLUS anywhere other than the default location will also need to add the following three lines (properly adjusted for their location):
(setq-default inferior-S+6-program-name "c:/progra~1/Insightful/SPLUS70/cmd/Splus") (setq-default inferior-Sqpe+6-SHOME-name "c:/progra~1/Insightful/SPLUS70") (setq-default inferior-Sqpe+6-program-name "c:/progra~1/Insightful/SPLUS70/cmd/Sqpe.exe")
The above example uses the default location of S-PLUS in
c:\progra~1\Insightful
. Please note that ESS
considers S-PLUS 6, 7, and 8 to be variants of S+6.
These users may also need to modify the emacs variable ess-SHOME-versions
to match their installation in order to get the full set of S-PLUS versions
on their machine into the ESS menu.
To start the S-PLUS [678].x GUI from ESS under emacs:
M-x S
(or M-x S+6
).
M-x S+6-msdos
C-c C-n
or C-c C-r
keys.
(If you are still using S-PLUS 4.x or 2000,\
then use M-x S+4
or M-x S+4-msdos
.)
To start an S-PLUS [678].x session inside an emacs buffer—and without the S-PLUS GUI:
M-x Sqpe
(or M-x Sqpe+6
).
This works with both the bash and msdos shells.
You will then be asked for a pathname ("S starting data
directory?"), from which to start the process. The prompt will
propose your current directory as the default.
You get Unix-like behavior, in particular the entire
transcript is available for emacs-style search commands.
Send lines or regions from the emacs buffer containing your S
program (for example, myfile.s) to the *S+6* buffer with the
C-c C-n
or C-c C-r
keys.
Interactive graphics are available with Sqpe by using the java
library supplied with S-PLUS 6.1 and newer releases.
Enter the commands:
library(winjava) java.graph()
Graphs can be saved from the java.graph
device
in several formats, but not PostScript. If you
need a PostScript file you will need to open a separate
postscript
device.
(If you are still using S-PLUS 4.x or 2000, then use M-x Sqpe+4
.)
To connect to an already running S-PLUS GUI (started, for example, from the S-PLUS icon):
M-x S+6-existing
or
M-x S+6-msdos-existing
You will then be
asked for a pathname ("S starting data directory?"), from which to
start the process. The prompt will propose your current directory
as the default. ESS will arrange for
communication with the already running S-PLUS GUI using the DDE protocol.
Send lines or regions
from the emacs buffer containing your S program (for example,
myfile.s) to the S-PLUS Commands Window with the
C-c C-n
or C-c C-r
keys.
(If you are still using S-PLUS 4.x or 2000,
then use M-x S+4-existing
or M-x S+4-msdos-existing
.)
If you wish to run R, you can start it with:
M-x R
XLispStat can not currently be run with
M-x XLS
Hopefully, this will change. However, you can still edit with emacs, and cut and paste the results into the XLispStat *Listener* Window under Microsoft Windows.
ESS is most likely to work with current/recent versions of the following statistical packages: R/S-PLUS, SAS, Stata and JAGS. The one exception is BUGS which is quite old, but should still work.
ESS supports current/recent versions of GNU Emacs and XEmacs. Most notably, the GNU Emacs 22 series and XEmacs 21.4.14 or higher (beta/pre-release versions are NOT SUPPORTED).
As well as using ESS to edit your source files for statistical programs, you can use ESS to run these statistical programs. In this chapter, we mostly will refer by example to running S from within emacs. The emacs convention is to name such processes running under its control as `inferior processes'. This term can be slightly misleading, in which case these processes can be thought of `interactive processes'. Either way, we use the term `iESS' to refer to the Emacs mode used to interact with statistical programs.
To start an S session on Unix or on Windows when you use the Cygwin bash shell, simply type M-x S RET.
To start an S session on Windows when you use the MSDOS prompt shell, simply type M-x S+6-msdos RET.
S will then (by default) ask the question
S starting data directory?
Enter the name of the directory you wish to start S from (that is,
the directory you would have cd
'd to before starting S from
the shell). This directory should have a .Data subdirectory.
You will then be popped into a buffer with name ‘*S*’ which will be used for interacting with the ESS process, and you can start entering commands.
ESS allows you to run more than one ESS process simultaneously in the same session. Each process has a name and a number; the initial process (process 1) is simply named (using S-PLUS as an example) ‘S+3:1’. The name of the process is shown in the mode line in square brackets (for example, ‘[S+3:2]’); this is useful if the process buffer is renamed. Without a prefix argument, M-x S starts a new ESS process, using the first available process number. With a prefix argument (for R), C-u M-x R allows for the specification of command line options.
You can switch to any active ESS process with the command ‘M-x ess-request-a-process’. Just enter the name of the process you require; completion is provided over the names of all running S processes. This is a good command to consider binding to a global key.
ESS works with processes on remote computers as easily as with processes on the local machine. The recommended way to access a statistical program on remote computer is to start it from a telnet or ssh buffer and then connect ESS to that buffer.
Should you or a colleague inadvertently start a statistical process in an ordinary ‘*shell*’ buffer, the ‘ess-remote’ command can be used to convert it to an ESS buffer and allow you to use the ESS commands with it.
We have two older commands, now deprecated, for accessing ESS processes on remote computers. See S+elsewhere and ESS-elsewhere.
These commands are now deprecated. We recommend ‘ess-remote’. We have two versions of the elsewhere function. ‘S+elsewhere’ is specific for the S-Plus program. The more general function ‘ESS-elsewhere’ is not as stable.
Or enter ‘M-x ESS-elsewhere’. You will be prompted for an ESS program and for a starting directory. I usually give it my project directory on the local machine, say ‘~myname/myproject/’
If you do not wish ESS to prompt for a starting directory when starting
a new process, set the variable ess-ask-for-ess-directory
to
nil
. In this case, the starting directory will be set using
one of the following methods:
ess-directory-function
stores the name of a
function, the value returned by this function is used. The default for
this variable is nil.
ess-directory
stores the name of a
directory (ending in a slash), this value is used. The default for this
variable is nil.
If ess-ask-for-ess-directory
has a non-nil
value (as it
does by default) then the value determined by the above rules provides
the default when prompting for the starting directory. Incidentally,
ess-directory
is an ideal variable to set in
ess-pre-run-hook
.
If you like to keep a record of your S sessions, set the variable
ess-ask-about-transfile
to t
, and you will be asked for a
filename for the transcript before the ESS process starts.
If non-
nil
, as for a file name in which to save the session transcript.
Enter the name of a file in which to save the transcript at the prompt. If the file doesn't exist it will be created (and you should give it a file name ending in ‘.St’); if the file already exists the transcript will be appended to the file. (Note: if you don't set this variable but you still want to save the transcript, you can still do it later — see Saving transcripts.)
Once these questions are answered (if they are asked at all) the S
process itself is started by calling the program name specified in the
variable inferior-ess-program
.
If you need to pass any arguments to this program, they may be specified
in the variable inferior-
S_program_name-args
(e.g. if
inferior-ess-program
is "S+"
then the variable to set is
inferior-S+-args
.
It is not normally necessary to pass arguments to the S program; in
particular do not pass the ‘-e’ option to Splus
, since ESS
provides its own command history mechanism.
By default, the new process will be displayed in the same window in the
current frame. If you wish your S process to appear in a separate
variable, customize the variable inferior-ess-own-frame
.
Alternatively, change inferior-ess-same-window
if you wish the
process to appear within another window of the current frame.
The primary function of the ESS package is to provide an easy-to-use front end to the S interpreter. This is achieved by running the S process from within an Emacs buffer, so that the Emacs editing commands are available to correct mistakes in commands, etc. The features of Inferior S mode are similar to those provided by the standard Emacs shell mode (see Shell Mode). Command-line completion of S objects and a number of `hot keys' for commonly-used S commands are also provided for ease of typing.
Sending a command to the ESS process is as simple as typing it in and pressing the <RETURN> key:
If you make a typing error before pressing RET all the usual Emacs editing commands are available to correct it (see Basic). Once the command has been corrected you can press <RETURN> (even if the cursor is not at the end of the line) to send the corrected command to the ESS process.
ESS provides some other commands which are useful for fixing mistakes:
backward-kill-word
) comint-kill-input
) comint-bol
) See Shell Mode, for other commands relevant to entering input.
In the process buffer, the <TAB> key is for completion, similar to that provided by Shell Mode for filenames. In Inferior S mode, pressing the <TAB> key when the cursor is following the first few characters of an object name completes the object name; if the cursor is following a file name TAB completes the file name.
When the cursor is just after a partially-completed object name,
pressing <TAB> provides completion in a similar fashion to
tcsh
except that completion is performed over all known S object names
instead of file names. ESS maintains a list of all objects known to S
at any given time, which basically consists of all objects (functions
and datasets) in every attached directory listed by the search()
command
along with the component objects of attached data frames
(if your version of S supports them).
For example, consider the three functions (available in Splus version
3.0) called binomplot()
, binom.test()
and
binomial()
. Typing bin TAB after the S prompt will
insert the characters ‘om’, completing the longest prefix
(‘binom’) which distinguishes these three commands. Pressing
TAB once more provides a list of the three commands which have
this prefix, allowing you to add more characters (say, ‘.’) which
specify the function you desire. After entering more characters
pressing TAB yet again will complete the object name up to
uniqueness, etc. If you just wish to see what completions exist without
adding any extra characters, type M-?.
ESS also provides completion over the components of named lists accessed
using the ‘$’ notation, to any level of nested lists. This feature
is particularly useful for checking what components of a list object
exist while partway through entering a command: simply type the object
name and ‘$’ and press TAB to see the names of existing list
components for that object.
Completion is also provided over file names, which is particularly
useful when using S functions such as get()
or scan()
which require fully expanded file names. Whenever the cursor is within
an S string, pressing TAB completes the file name before
point, and also expands any ‘~’ or environment variable references.
If the cursor is not in a string and does not follow a (partial) object name, the <TAB> key has a third use: it expands history references. See History expansion.
ESS automatically keeps track of any objects added or deleted to the system (such as new objects created, or directories added to the search list) to make completion as accurate as possible. Whenever ESS notices that search list has changed 1 when you attach a directory or data frame, the objects associated with it immediately become available for a completion; when it is detached completion is no longer available on those objects.
To maintain a list of accessible objects for completion, ESS needs to
determine which objects are contained in each directory or data frame on
the search list. This is done at the start of each S session, by
running the objects()
command on every element of the search
list.
Efficiency in completion is gained by maintaining a cache of objects currently known to S; when a new object becomes available or is deleted, only one component of the cache corresponding to the associated directory needs to be refreshed. If ESS ever becomes confused about what objects are available for completion (such as when if refuses to complete an object you know is there), the command M-x ess-resynch forces the entire cache to be refreshed, which should fix the problem.
Most of the time, the cursor spends most of its time at the bottom of the ESS process buffer, entering commands. However all the input and output from the current (and previous) ESS sessions is stored in the process buffer (we call this the transcript) and often we want to move back up through the buffer, to look at the output from previous commands for example.
Within the process buffer, a paragraph
is defined as the prompt, the command after the prompt, and the output
from the command. Thus M-{ and M-} move you backwards and
forwards, respectively, through commands in the transcript. A
particularly useful command is M-h (mark-paragraph
) which
will allow you to mark a command and its entire output (for deletion,
perhaps). For more information about paragraph commands,
see Paragraphs.
If an ESS process finishes and you restart it in the same process buffer, the output from the new ESS process appears after the output from the first ESS process separated by a form-feed (‘^L’) character. Thus pages in the ESS process buffer correspond to ESS sessions. Thus, for example, you may use C-x [ and C-x ] to move backward and forwards through ESS sessions in a single ESS process buffer. For more information about page commands, see Pages.
Viewing the output of the command you have just entered is a common occurrence and ESS provides a number of facilities for doing this. Whenever a command produces a longish output, it is possible that the window will scroll, leaving the next prompt near the middle of the window. The first part of the command output may have scrolled off the top of the window, even though the entire output would fit in the window if the prompt were near the bottom of the window. If this happens, you can use the command
comint-show-maximum-output
) to make more of the last output visible. (To make this happen
automatically for all inputs, set the variable
comint-scroll-to-bottom-on-input
to t
.)
If the first part of the output is still obscured, use
comint-show-output
) to view it. Finally, if you want to discard the last command output altogether, use
to delete it. Use this command judiciously to keep your transcript to a more manageable size.
If you want to view the output from more historic commands than the previous command, commands are also provided to move backwards and forwards through previously entered commands in the process buffer:
comint-previous-input
) comint-next-input
) Note that these two commands are analogous to C-p and C-n but apply to command lines rather than text lines. And just like C-p and C-n, passing a prefix argument to these commands means to move to the ARG'th next (or previous) command. (These commands are also discussed in Shell History Copying.)
There are also two similar commands (not bound to any keys by default) which move to preceding or succeeding commands, but which first prompt for a regular expression (see Syntax of Regular Expression), and then moves to the next (previous) command matching the pattern.
(comint-backward-matching-input regexp arg)
(comint-forward-matching-input regexp arg)
When moving through the transcript, you may wish to re-execute some of the commands you find there. ESS provides three commands to do this; these commands may be used whenever the cursor is within a command line in the transcript (if the cursor is within some command output, an error is signalled). Note all three commands involve the <RETURN> key.
inferior-ess-send-input
) comint-copy-old-input
) ess-transcript-send-command-and-move
) When the cursor is not after the current prompt, the <RETURN> key has a slightly different behavior than usual. Pressing RET on any line containing a command that you entered (i.e. a line beginning with a prompt) sends that command to the ESS process once again. If you wish to edit the command before executing it, use C-c RET instead; it copies the command to the current prompt but does not execute it, allowing you to edit it before submitting it.
These two commands leave the cursor at the new command line, allowing you to continue with interactive use of S. If you wish to resubmit a series of commands from the transcript, consider using M-RET instead, which leaves the cursor at the command line following the one you re-submitted. Thus by using M-RET repeatedly, you can re-submit a whole series of commands.
These commands work even if if the current line is a continuation line (i.e. the prompt is ‘+’ instead of ‘>’) — in this case all the lines that form the multi-line command are concatenated together and the resulting command is sent to the ESS process (currently this is the only way to resubmit a multi-line command to the ESS process in one go). If the current line does not begin with a prompt, an error is signalled. This feature, coupled with the command-based motion commands described above, could be used as a primitive history mechanism. ESS provides a more sophisticated mechanism, however, which is described in Command History.
To keep a record of your S session in a disk file, use the Emacs
command C-x C-w (write-file
) to attach a file to the
ESS process buffer. The name of the process buffer will (probably)
change to the name of the file, but this is not a problem. You can
still use S as usual; just remember to save the file before you quit
Emacs with C-x C-s. You can make ESS prompt you for a filename in
which to save the transcript every time you start S by setting the
variable
ess-ask-about-transfile
to t
; see Customizing startup.
We recommend you save your transcripts with filenames that end in
‘.St’. There is a special mode (ESS transcript mode —
see Transcript Mode) for editing transcript files which is
automatically selected for files with this suffix.
S transcripts can get very large, so some judicious editing is appropriate if you are saving it in a file. Use C-c C-o whenever a command produces excessively long output (printing large arrays, for example). Delete erroneous commands (and the resulting error messages or other output) by moving to the command (or its output) and typing M-h C-w. Also, remember that C-c C-e (and other hot keys) may be used for commands whose output you do not wish to appear in the transcript. These suggestions are appropriate even if you are not saving your transcript to disk, since the larger the transcript, the more memory your Emacs process will use on the host machine.
Finally, if you intend to produce S source code (suitable for using
with source()
or inclusion in an S function) from a
transcript, then the command M-x ess-transcript-clean-region may
be of use.
This command works in any Emacs buffer, and removes all prompts and
command output from an ESS transcript within the current region, leaving
only the commands. Don't forget to remove any erroneous commands first!
ESS provides easy-to-use facilities for re-executing or editing previous
commands. An input history of the last few commands is maintained (by
default the last 50 commands are stored, although this can be changed by
setting the variable comint-input-ring-size
in
inferior-ess-mode-hook
.) The simplest history commands simply
select the next and previous commands in the input history:
comint-previous-input
) comint-next-input
) For example, pressing M-p once will re-enter the last command into the process buffer after the prompt but does not send it to the ESS process, thus allowing editing or correction of the command before the ESS process sees it. Once corrections have been made, press RET to send the edited command to the ESS process.
If you want to select a particular command from the history by matching it against a regular expression (see Syntax of Regular Expression), to search for a particular variable name for example, these commands are also available:
comint-previous-matching-input
) comint-next-matching-input
) A common type of search is to find the last command that began with a particular sequence of characters; the following two commands provide an easy way to do this:
comint-previous-matching-input-from-input
) comint-next-matching-input-from-input
) Instead of prompting for a regular expression to match against, as they
instead select commands starting with those characters already entered.
For instance, if you wanted to re-execute the last attach()
command, you may only need to type att and then A-M-r and
RET. (Note: you may not have an <ALT> key on your keyboard,
in which case it may be a good idea to bind these commands to some other
keys.)
See Shell History Ring, for a more detailed discussion of the history mechanism.
Instead of searching through the command history using the command
described in the previous section, you can alternatively refer to a
historical command directly using a notation very similar to that used
in csh
. History references are introduced by a ‘!’ or
‘^’ character and have meanings as follows:
In addition, you may follow the reference with a word designator
to select particular words of the input. A word is defined as a
sequence of characters separated by whitespace. (You can modify this
definition by setting the value of comint-delimiter-argument-list
to a list of characters that are allowed to separate words and
themselves form words.) Words are numbered beginning with zero. The
word designator usually begins with a ‘:’ (colon) character;
however it may be omitted if the word reference begins with a ‘^’,
‘$’, ‘*’ or ‘-’. If the word is to be selected from the
previous command, the second ‘!’ character can be omitted from the
event specification. For instance, ‘!!:1’ and ‘!:1’ both
refer to the first word of the previous command, while ‘!!$’ and
‘!$’ both refer to the last word in the previous command. The
format of word designators is as follows:
In addition, you may surround the entire reference except for the first ‘!’ by braces to allow it to be followed by other (non-whitespace) characters (which will be appended to the expanded reference).
Finally, ESS also provides quick substitution; a reference like ‘^old^new^’ means “the last command, but with the first occurrence of the string ‘old’ replaced with the string ‘new’” (the last ‘^’ is optional). Similarly, ‘^old^’ means “the last command, with the first occurrence of the string ‘old’ deleted” (again, the last ‘^’ is optional).
To convert a history reference as described above to an input suitable for S, you need to expand the history reference, using the <TAB> key. For this to work, the cursor must be preceded by a space (otherwise it would try to complete an object name) and not be within a string (otherwise it would try to complete a filename). So to expand the history reference, type SPC TAB. This will convert the history reference into an S command from the history, which you can then edit or press <RET> to execute.
For example, to execute the last command that referenced the variable
data
, type !?data SPC TAB RET.
ESS provides a number of commands for executing the commonly used
functions. These commands below are basically information-gaining
commands (such as objects()
or search()
) which tend to
clutter up your transcript and for this reason some of the hot keys
display their output in a temporary buffer instead of the process buffer
by default. This behavior is controlled by the variable
ess-execute-in-process-buffer
which, if
non-nil
, means that these commands will produce their output in
the process buffer instead. In any case, passing a prefix argument to
the commands (with C-u) will reverse the meaning of
ess-execute-in-process-buffer
for that command, i.e. the output
will be displayed in the process buffer if it usually goes to a
temporary buffer, and vice-versa. These are the hot keys that behave in
this way:
ess-execute-objects
) objects()
command to the ESS process. A prefix argument specifies the
position on the search list (use a negative argument to toggle
ess-execute-in-process-buffer
as well). A quick way to see what
objects are in your working directory.
ess-execute-search
) search()
command to the ESS process.
ess-execute
) ess-execute
may seem pointless when you could just type the
command in anyway, but it proves useful for `spot' calculations which
would otherwise clutter your transcript, or for evaluating an expression
while partway through entering a command. You can also use this command
to generate new hot keys using the Emacs keyboard macro facilities;
see Keyboard Macros.
The following hot keys do not use ess-execute-in-process-buffer
to decide where to display the output — they either always display in
the process buffer or in a separate buffer, as indicated:
ess-execute-attach
) attach()
command.
If a numeric prefix argument is given it is used as the position on the
search list to attach the directory; otherwise the S default of 2 is
used. The attach()
command actually executed appears in the
process buffer.
ess-load-file
) source()
. If there is an error during loading, you can jump to
the error in the file with C-x ` (ess-parse-errors
).
See Error Checking, for more details.
ess-display-help-on-object
) ess-quit
) q()
command to the ESS process (or (exit)
to the XLS process), and cleans up any temporary buffers (such as
help buffers or edit buffers) you may have created along the way. Use
this command when you have finished your S session instead of simply
typing q()
yourself, otherwise you will need to issue the command
M-x ess-cleanup
command explicitly to make sure that all the files that need to be saved
have been saved, and that all the temporary buffers have been killed.
For the S languages (S, S-Plus, R) ESS sets an option in the current process that programs in the language can check to determine the environment in which they are currently running.
ESS sets
options(STERM="iESS")
for S language processes running in an
inferior iESS[S]
or iESS[R]
buffer.
ESS sets
options(STERM="ddeESS")
for independent S-Plus for Windows
processes running in the GUI and communicating with ESS via
the DDE (Microsoft Dynamic Data Exchange) protocol through a
ddeESS[S]
buffer.
Other values of options()$STERM
that we recommend are:
length
: Fixed length xterm or telnet window.
scrollable
: Unlimited length xterm or telnet window.
server
: S-Plus Stat Server.
BATCH
: BATCH.
Rgui
: R GUI.
Commands
: S-Plus GUI without DDE interface to ESS.
Additional values may be recommended in the future as new interaction
protocols are created. Unlike the values iESS
and ddeESS
,
ESS can't set these other values since the S language program is not
under the control of ESS.
When starting R or S under Unix, ESS sets
options(editor="emacsclient")
. (Under Microsoft Windows, it will
use gnuclient.exe rather than emacsclient, but the same principle
applies.) Within your R session, for example, if you have a function
called iterator
, typing fix(iterator)
, will show that
function in a temporary Emacs buffer. You can then correct the
function. When you kill the buffer, the definition of the function is
updated. Using edit()
rather than fix()
means that the
function is not updated. Finally, the S function page(x)
will
also show a text representation of the object x
in a temporary
Emacs buffer.
The following commands are also provided in the process buffer:
comint-interrupt-subjob
) ess-abort
) q()
nor
.Last
will be executed and device drivers will not finish
cleanly. This command is provided as a safety to
comint-stop-subjob
, which is usually bound to C-c C-z. If
you want to quit from S, use C-c C-q (ess-quit
) instead.
ess-dump-object-into-edit-buffer
) Other commands available in Inferior S mode are discussed in Shell Mode.
Inferior S mode records the transcript (the list of all commands executed, and their output) in the process buffer, which can be saved as a transcript file, which should normally have the suffix .St. The most obvious use for a transcript file is as a static record of the actions you have performed in a particular S session. Sometimes, however, you may wish to re-execute commands recorded in the transcript file by submitting them to a running ESS process. This is what Transcript Mode is for.
If you load file a with the suffix .St into Emacs, it is placed in S Transcript Mode. Transcript Mode is similar to Inferior S mode (see Entering commands): paragraphs are defined as a command and its output, and you can move though commands either with the paragraph commands or with C-c C-p and C-c C-n.
Three commands are provided to re-submit command lines from the transcript file to a running ESS process. They are:
ess-transcript-send-command
) ess-transcript-copy-command
) ess-transcript-send-command-and-move
) Note that these commands are similar to those on the same keys in Inferior S Mode. In all three cases, the commands should be executed when the cursor is on a command line in the transcript; the prompt is automatically removed before the command is submitted.
Yet another use for transcript files is to extract the command lines for inclusion in an S source file or function. Transcript mode provides one command which does just this:
ess-transcript-clean-region
) The remaining command lines may then be copied to a source file or edit buffer for inclusion in a function definition, or may be evaluated directly (see Evaluating code) using the code evaluation commands from S mode, also available in S Transcript Mode.
ESS[S] is the mode for editing S language files. This mode handles:
ESS[S] mode should be automatically turned on when loading a file with the suffices found in ess-site (*.R, *.S, *.s, etc). However, one will have to start up an inferior process to take advantage of the interactive features.
iESS (inferior ESS) is the mode for interfacing with active statistical processes (programs). This mode handles:
To start up iESS mode, use:
M-x S+3 M-x S4 M-x S+5 M-x S+6 M-x R
(for S-PLUS 3.x, S4, S+5, S+6 or S+7, and R, respectively. This assumes that you have access to each). Usually the site will have defined one of these programs (by default S+6) to the simpler name:
M-x S
In the (rare) case that you wish to pass command line arguments to the
starting S+6 process, set the variable inferior-Splus-args
.
Note that R has some extremely useful command line arguments. For
example, --vanilla
will ensure R starts up without loading in any init
files. To enter a command line argument, call R using a "prefix
argument", by
C-u M-x R
and when ESS prompts for "Starting Args ? ", enter (for example):
--vanilla
Then that R process will be started up using R --vanilla
. If you
wish to always call R with certain arguments, set the variable
inferior-R-args
accordingly.
If you have other versions of R or S-Plus available on the system, ESS
is also able to start those versions. How this exactly works depend on
which OS you are using, as described in the following paragraphs. The
general principle, regardless of OS, is that ESS searches the paths
listed in the variable exec-path
for R binaries. If ESS cannot
find your R binaries, on Unix you can change the unix environment
variable PATH
, as this variable is used to set exec-path
.
R on Unix systems: If you have "R-1.8.1" on your exec-path
, it
can be started using M-x R-1.8.1. By default, ESS will find
versions of R beginning "R-1" or "R-2". If your versions of R are
called other names, consider renaming them with a symbolic link or
change the variable ess-r-versions
. To see which functions have
been created for starting different versions of R, type M-x R- and
then hit [Tab]. These other versions of R can also be started from the
"ESS->Start Process->Other" menu.
R on Windows systems: If you have "rw1081" on your exec-path
, it
can be started using M-x rw1081. By default, ESS will find
versions of R located in directories parallel to the version of R in
your PATH
. If your versions of R are called other names, you
will need to change the variable ess-rterm-versions
. To see
which functions have been created for starting different versions of R,
type M-x rw and then hit [Tab]. These other versions of
R can also be started from the "ESS->Start Process->Other" menu.
Once ESS has found these extra versions of R, it will then create a new
function, called M-x R-newest, which will call the newest version
of R that it found. (ESS examines the date in the first line of
information from R --version
to determine which is newest.)
S on Unix systems: If you have "Splus7" on your exec-path
, it can
be started using M-x Splus7. By default, ESS will find all
executables beginning "Splus" on your path. If your versions of S are
called other names, consider renaming them with a symbolic link or
change the variable ess-s-versions
. To see which functions have
been created for starting different versions of Splus, type M-x
Splus and then hit [Tab]. These other versions of Splus can also be
started from the "ESS->Start Process->Other" menu.
A second mechanim is also available for running other versions of Splus.
The variable ess-s-versions-list
is a list of lists; each sublist
should be of the form: (DEFUN-NAME PATH ARGS). DEFUN-NAME is the name
of the new emacs function you wish to create to start the new S process;
PATH is the full path to the version of S you want to run; ARGS is an
optional string of command-line arguments to pass to the S process.
Here is an example setting:
(setq ess-s-versions-list '( ("Splus64" "/usr/local/bin/Splus64") ("Splus64-j" "/usr/local/bin/Splus64" "-j")))
which will then allow you to do M-x Splus64-j to start Splus64 with the corresponding command line arguments.
If you change the value of either ess-s-versions
or
ess-s-versions-list
, you should put them in your .emacs before
ess-site is loaded, since the new emacs functions are created when ESS
is loaded.
Sqpe (S-Plus running inside an emacs buffer) on Windows systems: If you
have an older version of S-Plus (S-Plus 6.1 for example) on your system,
ir can be started inside an emacs buffer with M-x splus61. By
default, ESS will find versions of S-Plus located in the installation
directories that Insightful uses by default. If your versions of S-Plus
are anywhere else, you will need to change the variable
ess-SHOME-versions
. To see which functions have been created for
starting different versions of S-Plus, type M-x spl and then hit
[Tab]. These other versions of S-Plus can also be started from the
"ESS->Start Process->Other" menu.
ESS has built-in facilities for viewing help files from S. See Help.
The first is preferred, and configured for. The second one can be retrieved again, by changing emacs variables.
1: (preferred by the current group of developers): The source code is real. The objects are realizations of the source code. Source for EVERY user modified object is placed in a particular directory or directories, for later editing and retrieval.
2: (older version): S objects are real. Source code is a temporary realization of the objects. Dumped buffers should not be saved. _We_strongly_discourage_this_approach_. However, if you insist, add the following lines to your .emacs file:
(setq ess-keep-dump-files 'nil) (setq ess-delete-dump-files t) (setq ess-mode-silently-save nil)
The second saves a small amount of disk space. The first allows for better portability as well as external version control for code.
We present some basic suggestions for using ESS to interact with S. These are just a subset of approaches, many better approaches are possible. Contributions of examples of how you work with ESS are appreciated (especially since it helps us determine priorities on future enhancements)! (comments as to what should be happening are prefixed by "##").
1: ## Data Analysis Example (source code is real) ## Load the file you want to work with C-x C-f myfile.s ## Edit as appropriate, and then start up S-PLUS 3.x M-x S+3 ## A new buffer *S+3:1* will appear. Splus will have been started ## in this buffer. The buffer is in iESS [S+3:1] mode. ## Split the screen and go back to the file editing buffer. C-x 2 C-x b myfile.s ## Send regions, lines, or the entire file contents to S-PLUS. For regions, ## highlight a region with keystrokes or mouse and then send with: C-c C-r ## Re-edit myfile.s as necessary to correct any difficulties. Add ## new commands here. Send them to S by region with C-c C-r, or ## one line at a time with C-c C-n. ## Save the revised myfile.s with C-x C-s. ## Save the entire *S+3:1* interaction buffer with C-c C-s. You ## will be prompted for a file name. The recommended name is ## myfile.St. With the *.St suffix, the file will come up in ESS ## Transcript mode the next time it is accessed from Emacs. 2: ## Program revision example (source code is real) ## Start up S-PLUS 3.x in a process buffer (this will be *S+3:1*) M-x S+3 ## Load the file you want to work with C-x C-f myfile.s ## edit program, functions, and code in myfile.s, and send revised ## functions to S when ready with C-c C-f ## or highlighted regions with C-c C-r ## or individual lines with C-c C-n ## or load the entire buffer with C-c C-l ## save the revised myfile.s when you have finished C-c C-s 3: ## Program revision example (S object is real) ## Start up S-PLUS 3.x in a process buffer (this will be *S+3:1*) M-x S+3 ## Dump an existing S object my.function into a buffer to work with C-c C-d my.function ## a new buffer named yourloginname.my.function.S will be created with ## an editable copy of the object. The buffer is associated with the ## pathname /tmp/yourloginname.my.function.S and will amlost certainly not ## exist after you log off. ## enter program, functions, and code into work buffer, and send ## entire contents to S-PLUS when ready C-c C-b ## Go to *S+3:1* buffer, which is the process buffer, and examine ## the results. C-c C-y ## The sequence C-c C-y is a shortcut for: C-x b *S+3:1* ## Return to the work buffer (may/may not be prefixed) C-x C-b yourloginname.my.function.S ## Fix the function that didn't work, and resubmit by placing the ## cursor somewhere in the function and C-c C-f ## Or you could've selected a region (using the mouse, or keyboard ## via setting point/mark) and C-c C-r ## Or you could step through, line by line, using C-c C-n ## Or just send a single line (without moving to the next) using C-c C-j ## To fix that error in syntax for the "rchisq" command, get help ## by C-c C-v rchisq 4: Data Analysis (S object is real) ## Start up S-PLUS 3.x, in a process buffer (this will be *S+3:1*) M-x S+3 ## Work in the process buffer. When you find an object that needs ## to be changed (this could be a data frame, or a variable, or a ## function), dump it to a buffer: C-c C-d my.cool.function ## Edit the function as appropriate, and dump back in to the ## process buffer C-c C-b ## Return to the S-PLUS process buffer C-c C-y ## Continue working. ## When you need help, use C-c C-v rchisq ## instead of entering: help("rchisq")
1. Suppose that you are primarily an SPLUS 3.4 user, occasionally using S version 4, and sick and tired of the buffer-name *S+3* we've stuck you with. Simply edit the "ess-dialect" alist entry in the essd-sp3.el and essd-s4.el files to be "S" instead of "S4" and "S+3". This will ensure that all the inferior process buffer names are "*S*".
2. Suppose that you WANT to have the first buffer name indexed by ":1", in the same manner as your S-PLUS processes 2,3,4, and 5 (for you heavy simulation people). Then uncomment the line in ess-site (or add after your (require 'ess-site) or (load "ess-site") command in your .emacs file, the line:
(setq ess-plain-first-buffername nil)
)
3. Fontlocking sometimes fails to behave nicely upon errors. When Splus dumps, a mis-matched " (double-quote) can result in the wrong font-lock face being used for the remainder of the buffer.
Solution: add a " at the end of the "Dumped..." statement, to revert the font-lock face back to normal.
4. When you change directory within a *R* or *S* session using the setwd() command, emacs does not recognise that you have changed the current directory.
Solution: Use M-x ess-change-directory. This will
ensure that Emacs will know that you have changed the directory, and
update the emacs variable default-directory
.
ESS provides facilities for editing S objects within your Emacs session. Most editing is performed on S functions, although in theory you may edit datasets as well. Edit buffers are always associated with files, although you may choose to make these files temporary if you wish. Alternatively, you may make use of a simple yet powerful mechanism for maintaining backups of text representations of S functions. Error-checking is performed when S code is loaded into the ESS process.
from within the ESS process buffer (*S*
). You will then be
prompted for an object to edit: you may either type in the name of an
existing object (for which completion is available using the TAB
key),
or you may enter the name of a new object.
A buffer will be created containing the text representation of the
requested object or, if you entered the name of a non-existent object at
the prompt and the variable ess-function-template
is non-nil
, you will be presented with a template defined by that
variable, which defaults to a skeleton function construct.
You may then edit the function as required. The edit buffer generated
by ess-dump-object-into-edit-buffer
is placed in the ESS
major mode which provides a number of commands to facilitate editing
S source code. Commands are provided to intelligently indent S
code, evaluate portions of S code and to move around S code
constructs.
Note: when you dump a file with C-c C-d, ESS first checks
to see whether there already exists an edit buffer containing that
object and, if so, pops you directly to that buffer. If not, ESS next
checks whether there is a file in the appropriate place with the
appropriate name (see Source Files) and if so, reads in that file.
You can use this facility to return to an object you were editing in a
previous session (and which possibly was never loaded to the S
session). Finally, if both these tests fail, the ESS process is
consulted and a dump()
command issued.
If you want to force ESS to ask the ESS process for the object's
definition (say, to reformat an unmodified buffer or to revert back to
S's idea of the object's definition) pass a prefix argument to
ess-dump-object-into-edit-buffer
by typing C-u C-c C-d.
The best way to get information — particularly function definitions
— into S is to load them in as source file, using S's
source
function. You have already seen how to create source
files using C-c C-d; ESS provides a complementary command for
loading source files (even files not created with ESS!) into the ESS
process:
After typing C-c C-l you will prompted for the name of the file to load into S; usually this is the current buffer's file which is the default value (selected by simply pressing RET at the prompt). You will be asked to save the buffer first if it has been modified (this happens automatically if the buffer was generated with C-c C-d). The file will then be loaded, and if it loads successfully you will be returned to the ESS process.
If any errors occur when loading a file with C-c C-l
, ESS will
inform you of this fact. In this case, you can jump directly to the
line in the source file which caused the error by typing C-c `
(ess-parse-errors
).
You will be returned to the offending file (loading it into a buffer if
necessary) with point at the line S reported as containing the
error. You may then correct the error, and reload the file. Note that
none of the commands in an S source file will take effect if any
part of the file contains errors.
Sometimes the error is not caused by a syntax error (loading a
non-existent file for example). In this case typing C-c ` will
simply display a buffer containing S's error message. You can force
this behavior (and avoid jumping to the file when there is a
syntax error) by passing a prefix argument to ess-parse-errors
with C-u C-c `.
Other commands are also available for evaluating portions of code in the
S process. These commands cause the selected code to be evaluated
directly by the ESS process as if you had typed them in at the
command line; the source()
function is not used. You may choose
whether both the commands and their output appear in the process buffer
(as if you had typed in the commands yourself) or if the output alone is
echoed. The behavior is controlled by the variable
ess-eval-visibly-p
whose default is nil
(display output only). Passing a prefix argument (C-u) to any of
the following commands, however, reverses the meaning of
ess-eval-visibly-p
for that command only — for example C-u
C-c C-j echoes the current line of S (or other) code in the ESS
process buffer, followed by its output. This method of evaluation is an
alternative to S's source()
function
when you want the input as well as the output to be displayed. (You can
sort of do this with source()
when the option echo=T
is
set, except that prompts do not get displayed. ESS puts prompts in the
right places.) The commands for evaluating code are:
ess-eval-line
) ess-eval-line-and-go
) ess-eval-function
) ess-eval-function-and-go
) ess-eval-region
) ess-eval-region-and-go
) ess-eval-buffer
) ess-eval-buffer-and-go
) ess-eval-line-and-step
) It should be stressed once again that these ess-eval-
commands
should only be used for evaluating small portions of code for debugging
purposes, or for generating transcripts from source files. When editing
S functions, C-c C-l is the command to use to update the
function's value. In particular, ess-eval-buffer
is now largely
obsolete.
One final command is provided for spot-evaluations of S code:
ess-execute-in-tb
) This is useful for quick calculations, etc.
All the above commands are useful for evaluating small amounts of code
and observing the results in the process buffer. A useful way to work
is to divide the frame into two windows; one containing the source code
and the other containing the process buffer. If you wish to make the
process buffer scroll automatically when the output reaches the bottom
of the window, you will need to set the variable
comint-scroll-to-bottom-on-output
to 'others
or t
.
ESS now provides a sophisticated mechanism for indenting S source
code (thanks to Ken'ichi Shibayama). Compound statements (delimited by
‘{’ and ‘}’) are indented relative to their enclosing block.
In addition, the braces have been electrified to automatically indent to
the correct position when inserted, and optionally insert a newline at
the appropriate place as well. Lines which continue an incomplete
expression are indented relative to the first line of the expression.
Function definitions, if
statements, calls to expression()
and loop constructs are all recognized and indented appropriately. User
variables are provided to control the amount if indentation in each
case, and there are also a number of predefined indentation styles to
choose from.
Comments are also handled specially by ESS, using an idea borrowed from
the Emacs-Lisp indentation style. By default,
comments beginning with ‘###’
are aligned to the beginning of the line. Comments beginning with
‘##’ are aligned to the current level of indentation for the block
containing the comment. Finally, comments beginning with ‘#’ are
aligned to a column on the right (the 40th column by default, but this
value is controlled by the variable comment-column
,)
or just after the expression on the line containing the comment if it
extends beyond the indentation column. You turn off the default
behavior by adding the line
(setq ess-fancy-comments nil)
to your .emacs file.
ESS now has preliminary support for editing roxygen tags within R mode
buffers. In particular, when the function ess-roxygen-fn
(bound
to C-c C-o) is called with point inside a R function, the roxygen
template for the function is added just above the function.
The indentation commands provided by ESS are:
ess-indent-command
) newline-and-indent
) ess-indent-exp
) ess-electric-brace
) indent-for-comment
) GNU
, BSD
, K&R
, CLB
, and C++
.
The DEFAULT
style uses the default values for the indenting
variables (unless they have been modified in your .emacs file.)
This command causes all of the formatting variables to be buffer-local.
A number of commands are provided to move across function definitions in the edit buffer:
ess-beginning-of-function
) ess-end-of-function
) ess-mark-function
) Completion is provided in the edit buffer in a similar fashion to the process buffer: M-TAB completes file names and M-? lists file completions. Since <TAB> is used for indentation in the edit buffer, object completion is now performed with C-c TAB. Note however that completion is only provided over globally known S objects (such as system functions) — it will not work for arguments to functions or other variables local to the function you are editing.
Finally, two commands are provided for returning to the ESS process buffer:
ess-switch-to-end-of-ESS
) ess-switch-to-ESS
) In addition some commands available in the process buffer are also available in the edit buffer. You can still read help files with C-c C-v, edit another function with C-c C-d and of course C-c C-l can be used to load a source file into S. See Other, for more details on these commands.
Every edit buffer in ESS is associated with a dump file on disk.
Dump files are created whenever you type C-c C-d
(ess-dump-object-into-edit-buffer
), and may either be deleted
after use, or kept as a backup file or as a means of keeping several
versions of an S function.
If non-
nil
, dump files created with C-c C-d are deleted immediately after they are created by the ess-process.
Since immediately after S dumps an object's definition to a disk
file the source code on disk corresponds exactly to S's idea of the
object's definition, the disk file isn't needed; deleting it now has the
advantage that if you don't modify the file (say, because you
just wanted to look at the definition of one of the standard S
functions) the source dump file won't be left around when you kill the
buffer. Note that this variable only applies to files generated with
S's dump
function; it doesn't apply to source files which already
exist. The default value is t
.
Option controlling what to do with the dump file after an object has been successfully loaded into S. Valid values are
nil
(always delete),ask
(always ask whether to delete),check
(delete files generated with C-c C-d in this Emacs session, otherwise ask — this is the default) andt
(never delete). This variable is buffer-local.
After an object has been successfully (i.e. without error) loaded back into S with C-c C-l, the disk file again corresponds exactly (well, almost — see below) to S's record of the object's definition, and so some people prefer to delete the disk file rather than unnecessarily use up space. This option allows you to do just that.
If the value of ess-keep-dump-files
is t
, dump files are
never deleted after they are loaded. Thus you can maintain a complete
text record of the functions you have edited within ESS. Backup files
are kept as usual, and so by using the Emacs numbered backup facility —
see Single or Numbered Backups, you can keep a historic
record of function definitions. Another possibility is to maintain the
files with a version-control system such as RCS See Version Control. As long as a dump file exists in the appropriate place for a
particular object, editing that object with C-c C-d finds that
file for editing (unless a prefix argument is given) — the ESS
process is not consulted. Thus you can keep comments outside the
function definition as a means of documentation that does not clutter
the S object itself. Another useful feature is that you may format
the code in any fashion you please without S re-indenting the code
every time you edit it. These features are particularly useful for
project-based work.
If the value of ess-keep-dump-files
is nil, the dump file is always
silently deleted after a successful load with C-c C-l. While this
is useful for files that were created with C-c C-d it also applies
to any other file you load (say, a source file of function
definitions), and so can be dangerous to use unless you are careful.
Note that since ess-keep-dump-files
is buffer-local, you can make
sure particular files are not deleted by setting it to t
in the
Local Variables section of the file See Local Variables in Files.
A safer option is to set ess-keep-dump-files
to ask
; this
means that ESS will always ask for confirmation before deleting the
file. Since this can get annoying if you always want to delete dump
files created with C-c C-d
, but not any other files, setting
ess-keep-dump-files
to check
(the default value) will
silently delete dump files created with C-c C-d in the current
Emacs session, but query for any other file. Note that in any case you
will only be asked for confirmation once per file, and your answer is
remembered for the rest of the Emacs session.
Note that in all cases, if an error (such as a syntax error) is detected while loading the file with C-c C-l, the dump file is never deleted. This is so that you can edit the file in a new Emacs session if you happen to quit Emacs before correcting the error.
Dump buffers are always autosaved, regardless of the value of
ess-keep-dump-files
.
Every dump file should be given a unique file name, usually the dumped object name with some additions.
Template for filenames of dumped objects.
%s
is replaced by the object name.
By default, dump file names are the user name, followed by ‘.’ and
the object and ending with ‘.S’. Thus if user joe
dumps the
object myfun
the dump file will have name joe.myfun.S.
The username part is included to avoid clashes when dumping into a
publicly-writable directory, such as /tmp; you may wish to remove
this part if you are dumping into a directory owned by you.
You may also specify the directory in which dump files are written:
Directory name (ending in a slash) where S dump files are to be written.
By default, dump files are always written to /tmp, which is fine
when ess-keep-dump-files
is nil
. If you are keeping dump
files, then you will probably want to keep them somewhere in your home
directory, say ~/S-source. This could be achieved by including
the following line in your .emacs file:
(setq ess-source-directory (expand-file-name "~/S-source/"))
If you would prefer to keep your dump files in separate directories
depending on the value of some variable, ESS provides a facility for
this also. By setting ess-source-directory
to a lambda
expression which evaluates to a directory name, you have a great deal of
flexibility in selecting the directory for a particular source file to
appear in. The lambda expression is evaluated with the process buffer
as the current buffer and so you can use the variables local to that
buffer to make your choice. For example, the following expression
causes source files to be saved in the subdirectory Src of the
directory the ESS process was run in.
(setq ess-source-directory (lambda () (concat ess-directory "Src/")))
(ess-directory
is a buffer-local variable in process buffers
which records the directory the ESS process was run from.) This is
useful if you keep your dump files and you often edit objects with the
same name in different ESS processes. Alternatively, if you often
change your S working directory during an S session, you may
like to keep dump files in some subdirectory of the directory pointed to
by the first element of the current search list. This way you can edit
objects of the same name in different directories during the one S
session:
(setq ess-source-directory (lambda () (file-name-as-directory (expand-file-name (concat (car ess-search-list) "/.Src")))))
If the directory generated by the lambda function does not exist but can be created, you will be asked whether you wish to create the directory. If you choose not to, or the directory cannot be created, you will not be able to edit functions.
ESS also provides support for editing R documentation (“Rd”) files. R objects are documented in files written in Rd format, a simple markup language closely resembling (La)TeX, which can be processed into a variety of formats, including LaTeX, HTML, and plain text. Rd format is described in section “Rd format” of the “Writing R Extensions” manual in the R distribution.
Visiting an Rd file as characterized by its extension Rd will activate Rd Mode, which provides several facilities for making editing R documentation files more convenient, by helping with indentation, insertions, even doing some of the typing for you (with Abbrev Mode), and by showing Rd keywords, strings, etc. in different faces (with Font Lock Mode).
Note that R also accepts Rd files with extension rd; to activate ESS[Rd] support for this extension, you may need to add
(add-to-list 'auto-mode-alist '("\\.rd\\'" . Rd-mode))
to one of your Emacs startup files.
In Rd mode, the following special Emacs commands can be used in addition to the standard Emacs commands.
reindent-then-newline-and-indent
). An abbrev before point is
expanded if abbrev-mode
is non-nil
.
indent-according-to-mode
).
Rd-mode-insert-skeleton
). Note that many users
might prefer to use the R function prompt
on an existing R object
to generate a non-empty Rd “shell” documenting the object (which
already has all information filled in which can be obtained from the
object).
Rd-font
). C-c C-f is only a prefix; see
e.g. C-c C-f TAB for the available bindings. Note that
currently, not all of the Rd text markup as described in section
“Marking text” of “Writing R Extensions” can be accessed via
C-c C-f.
Rd-mode-insert-item
).
Rd-preview-help
).
In addition, when editing Rd files one can interact with a running R process in a similar way as when editing R language files. E.g., C-c C-v provides access to on-line help, and C-c C-n sends the current line to the R process for evaluation. This interaction is particularly useful when editing the examples in the Rd file. See C-h m for all available commands.
Rd mode also provides access to abbreviations for most of the Rd markup commands. Type M-x list-abbrevs with Abbrev mode turned on to list all available abbrevs. Note that all Rd abbrevs start with a grave accent.
Rd mode can be customized via the following variables.
Rd-mode-hook
Rd-indent-level
Rd-to-help-command
To automatically turn on the abbrev and font-lock features of Rd mode, add the following lines to one of your Emacs startup files:
(add-hook 'Rd-mode-hook (lambda () (abbrev-mode 1) (font-lock-mode 1)))
ESS provides an easy-to-use facility for reading S help files from
within Emacs. From within the ESS process buffer or any ESS edit
buffer, typing C-c C-v (ess-display-help-on-object
)
will prompt you for the name of an object for which you would like
documentation. Completion is provided over all objects which have help
files.
If the requested object has documentation, you will be popped into a
buffer (named *help(
obj-name)*
) containing the help file.
This buffer is placed in a special `S Help' mode which disables the
usual editing commands but which provides a number of keys for paging
through the help file:
ess-describe-help-mode
) ess-display-help-on-object
) Paging commands:
scroll-down
) scroll-up
) beginning-of-buffer
) and < (end-of-buffer
)
Section-based motion commands:
ess-skip-to-next-section
) and p
(ess-skip-to-previous-section
) In addition, the s key followed by one of the following letters will jump to a particular section in the help file. Note that R uses capitalized instead of all-capital section headers, e.g., ‘Description:’ instead of ‘DESCRIPTION:’ and also only some versions of S(-plus) have sections ‘BACKGROUND’, ‘BUGS’, ‘OPTIONAL ARGUMENTS’, ‘REQUIRED ARGUMENTS’, and ‘SIDE EFFECTS’.
Do use s ? to get the current list of active key bindings.
Miscellaneous:
ess-eval-line-and-step
) ess-eval-region
) isearch-forward
) Quit commands:
ess-switch-to-end-of-ESS
) kill-buffer
) ess-kill-buffer-and-go
) In addition, all of the ESS commands available in the edit buffers are also available in S help mode (see Edit buffer). Of course, the usual (non-editing) Emacs commands are available, and for convenience the digits and <-> act as prefix arguments.
If a help buffer already exists for an object for which help is
requested, that buffer is popped to immediately; the ESS process is
not consulted at all. If the contents of the help file have changed,
you either need to kill the help buffer first, or pass a prefix argument
(with C-u) to ess-display-help-on-object
.
Help buffers are marked as temporary buffers in ESS, and are deleted
when ess-quit
or ess-cleanup
are called.
Help buffers normally appear in another window within the current
frame. If you wish help buffers to appear in their own frame (either
one per help buffer, or one for all help buffers), you can customize the
variable ess-help-own-frame
.
ESS[SAS] was designed for use with SAS. It is descended from emacs
macros developed by John Sall for editing SAS programs and SAS-mode
by
Tom Cook. Those editing features and new advanced features are part of
ESS[SAS]. The user interface of ESS[SAS] has similarities with ESS[S]
and the SAS Display Manager.
ESS[SAS] was designed to aid the user in writing and maintaining SAS programs, such as foo.sas. Both interactive and batch submission of SAS programs is supported.
ESS[SAS] was written with two primary goals.
ESS[SAS] is the mode for editing SAS language files. This mode handles:
ESS[SAS] is automatically turned on when editing a file with a .sas
suffix (or other extension, if specified via auto-mode-alist
). The function
keys can be enabled to use the same function keys that
the SAS Display Manager does. The interactive capabilities of ESS require you
to start an inferior SAS process with M-x SAS
(See iESS(SAS)–Interactive SAS processes.)
At this writing, the indenting and syntax highlighting are generally
correct. Known issues: for multiple line *
or %*
comments, only the
first line is highlighted; for .log files, only the first line of a
NOTE:
, WARNING:
or ERROR:
message is highlighted; unmatched
single/double quotes in CARDS
data lines are NOT ignored; in an
iterative DO
statement, TO
and BY
are not highlighted.
Two options. The <TAB> key is bound by default to sas-indent-line
. This
function is used to syntactically indent SAS code so PROC
and RUN
are in
the left margin, other statements are indented sas-indent-width
spaces from the margin,
continuation lines are indented sas-indent-width
spaces in from the beginning column of
that statement. This is the type of functionality that emacs provides
in most programming language modes. This functionality is equivalent to
uncommenting the following line in ess-site.el:
(setq ess-sas-edit-keys-toggle nil)
ESS provides an alternate behavior for <TAB> that makes it behave as it does in SAS Display Manager, i.e. move the cursor to the next stop. The alternate behavior also provides a "TAB" backwards, C-<TAB>, that moves the cursor to the stop to the left and deletes any characters between them. This functionality is obtained by uncommenting the following line in ess-site.el:
(setq ess-sas-edit-keys-toggle t)
Under the alternate behavior, <TAB> is bound to M-x tab-to-tab-stop
and the stops are defined by ess-sas-tab-stop-list
.
Submission of a SAS batch job is dependent on your environment.
ess-sas-submit-method
is determined by your operating system and
your shell. It defaults to 'sh
unless you are running Windows or
Mac Classic. Under Windows, it will default to 'sh
if you are using
a UNIX-imitating shell; otherwise 'ms-dos
for an MS-DOS
shell. On Mac OS X, it will default to 'sh
, but under Mac Classic,
it defaults to 'apple-script
. You will also set this to 'sh
if the SAS batch job needs to run on a remote machine rather than your
local machine. This works transparently if you are editing the remote file
via ange-ftp/EFS or tramp. Note that
ess-sas-shell-buffer-remote-init
is a Local Variable that defaults
to "ssh"
which will be used to open the buffer on the remote host
and it is assumed that no password is necessary, i.e. you are using
ssh-agent
/ssh-add
or the equivalent (see the discussion about
Local Variables below if you need to change the default).
However, if you are editing the file locally and transferring it back and
forth with Kermit, you need some additional steps. First, start Kermit
locally before remotely logging in. Open a local copy of the file with the
ess-kermit-prefix
character prepended (the default is "#"
).
Execute the command M-x ess-kermit-get which automatically brings
the contents of the remote file into your local copy. If you transfer
files with Kermit manually in a *shell* buffer, then note that the
Kermit escape sequence is C-q C- c rather than C- c which
it would be in an ordinary terminal application, i.e. not in an emacs
buffer. Lastly, note that the remote Kermit command is specified by
ess-kermit-command
.
The command used by the SUBMIT
function key (<F3> or <F8>)
to submit a batch SAS job, whether local or remote, is
ess-sas-submit-command
which defaults to sas-program
.
sas-program
is "invoke SAS using program file"
for Mac
Classic and "sas"
otherwise. However, you may have to alter
ess-sas-submit-command
for a particular program, so it is defined as
buffer-local. Conveniently, it can be set at the end of the program:
endsas; Local variables: ess-sas-submit-command: "sas8" End:
The command line is also made of ess-sas-submit-pre-command
,
ess-sas-submit-post-command
and ess-sas-submit-command-options
(the last of which is also buffer-local).
Here are some examples for your ~/.emacs or ~/.xemacs/init.el
file (you may also use M-x customize-variable):
;'sh default (setq ess-sas-submit-pre-command "nohup") ;'sh default (setq ess-sas-submit-post-command "-rsasuser &") ;'sh example (setq-default ess-sas-submit-command "/usr/local/sas/sas") ;'ms-dos default (setq ess-sas-submit-pre-command "start") ;'ms-dos default (setq ess-sas-submit-post-command "-rsasuser -icon") ;Windows example (setq-default ess-sas-submit-command "c:/progra~1/sas/sas.exe") ;Windows example (setq-default ess-sas-submit-command "c:\\progra~1\\sas\\sas.exe")
There is a built-in delay before a batch SAS job is submitted when using a UNIX-imitating shell under Windows. This is necessary in many cases since the shell might not be ready to receive a command. This delay is currently set high enough so as not to be a problem. But, there may be cases when it needs to be set higher, or could be set much lower to speed things up. You can over-ride the default in your ~/.emacs or ~/.xemacs/init.el file by:
(setq ess-sleep-for 0.2)
For example, (setq ess-sas-global-unix-keys t)
keys shown,
(setq ess-sas-global-pc-keys t)
in parentheses;
ESS[SAS] function keys are presented in the next section.
Open the file you want to work with C-x C-f foo.sas.
foo.sas will be in ESS[SAS] mode. Edit as appropriate, then save and
submit the batch SAS job.
<F3> (<F8>)
The job runs in the *shell* buffer while you continue to edit
foo.sas. If ess-sas-submit-method
is 'sh
, then the
message buffer will display the shell notification when the
job is complete. The 'sh
setting also allows you to
terminate the SAS batch job before it is finished.
<F8> (<F3>)
Terminating a SAS batch in the *shell* buffer.
kill PID
You may want to visit the .log (whether the job is still running or it is finished) and check for error messages. The .log will be refreshed and you will be placed in it's buffer. You will be taken to the first error message, if any.
<F5> (<F6>)
Goto the next error message, if any.
<F5> (<F6>)
Now, ‘refresh’ the .lst and go to it's buffer.
<F6> (<F7>)
If you wish to make changes, go to the .sas file with.
<F4> (<F5>)
Make your editing changes and submit again.
<F3> (<F8>)
The setup of function keys for SAS batch processing is unavoidably complex, but the usage of function keys is simple. There are five distinct options:
Option 1 (default). Function keys in ESS[SAS] are not bound to elisp commands. This is in accordance with the GNU Elisp Coding Standards (GECS) which do not allow function keys to be bound so that they are available to the user.
Options 2-5. Since GECS does not allow function keys to be bound by modes, these keys are often unused. So, ESS[SAS] provides users with the option of binding elisp commands to these keys. Users who are familiar with SAS will, most likely, want to duplicate the function key capabilities of the SAS Display Manager. There are four options (noted in parentheses).
auto-mode-alist
.
The distinction between local and global is subtle. If you want the ESS[SAS] definitions to work when you are in the *shell* buffer or when editing files other than the file extensions that ESS[SAS] recognizes, you will most likely want to use the global definitions. If you want your function keys to understand SAS batch commands when you are editing SAS files, and to behave normally when editing other files, then you will choose the local definitions. The option can be chosen by the person installing ESS for a site or by an individual.
;;2; (setq ess-sas-local-unix-keys t) ;;3; (setq ess-sas-local-pc-keys t) ;;4; (setq ess-sas-global-unix-keys t) ;;5; (setq ess-sas-global-pc-keys t)
The names -unix-
and -pc-
have nothing to do with the operating system
that you are running. Rather, they mimic the definitions that the SAS
Display Manager uses by default on those platforms.
(load "ess-site") ;; local-unix-keys (ess-sas-global-pc-keys)
Finally, we get to what the function keys actually do. You may recognize some of the nicknames as SAS Display Manager commands (they are in all capitals).
UNIX | PC | Nickname
|
<F2> | <F2> | ‘refresh’
|
revert the current buffer with the file of the same
name if the file is newer than the buffer
| ||
<F3> | <F8> | SUBMIT
|
save the current .sas file (which is either the .sas
file in the current buffer or the .sas file associated
with the .lst or .log file in the current buffer)
and submit the file as a batch SAS job
| ||
<F4> | <F5> | PROGRAM
|
switch buffer to .sas file
| ||
<F5> | <F6> | LOG
|
switch buffer to .log file, ‘refresh’ and goto next
error message, if any
| ||
<F6> | <F7> | OUTPUT
|
switch buffer to .lst file and ‘refresh’
| ||
<F7> | <F4> | ‘filetype-1’
|
switch buffer to ‘filetype-1’ (defaults to .txt) file
and ‘refresh’
| ||
<F8> | <F3> | ‘shell’
|
switch buffer to *shell*
| ||
<F9> | <F9> | VIEWTABLE
|
open an interactive PROC FSEDIT session on the SAS
dataset near point
| ||
<F10> | <F10> | toggle-log
|
toggle ESS[SAS] for .log files; useful for certain
debugging situations
| ||
<F11> | <F11> | ‘filetype-2’
|
switch buffer to ‘filetype-2’ (defaults to .dat) file
and ‘refresh’
| ||
<F12> | <F12> | viewgraph
|
open a GSASFILE near point for viewing either in emacs
or with an external viewer
| ||
C-<F1> | C-<F1> | rtf-portrait
|
create an MS RTF portrait file from the current buffer
with a file extension of .rtf
| ||
C-<F2> | C-<F2> | rtf-landscape
|
create an MS RTF landscape file from the current buffer
with a file extension of .rtf
| ||
C-<F3> | C-<F8> | submit-region
|
write region to ess-temp.sas and submit
| ||
C-<F5> | C-<F6> | append-to-log
|
append ess-temp.log to the current .log file
| ||
C-<F6> | C-<F7> | append-to-output
|
append ess-temp.lst to the current .lst file
| ||
C-<F9> | C-<F9> | INSIGHT
|
open an interactive PROC INSIGHT session on the SAS
dataset near point
| ||
C-<F10> | C-<F10> | toggle-listing
|
toggle ESS[SAS] for .lst files; useful for toggling
read-only
|
SUBMIT
, PROGRAM
, LOG
and OUTPUT
need no further
explanation since they mimic the SAS Display Manager commands and
related function key definitions. However, six other keys have been
provided for convenience and are described below.
‘shell’ switches you to the *shell* buffer where you can
interact with your operating system. This is especially helpful if you
would like to kill a SAS batch job. You can specify a different buffer
name to associate with a SAS batch job (besides *shell*) with the
buffer-local variable ess-sas-shell-buffer
. This allows you to have
multiple buffers running SAS batch jobs on multiple local/remote
computers that may rely on different methods specified by the buffer-local
variable ess-sas-submit-method
.
<F2> performs the ‘refresh’ operation on the current buffer.
‘refresh’ compares the buffer's last modified date/time with the
file's last modified date/time and replaces the buffer with the file if the
file is newer. This is the same operation that is automatically performed
when LOG
, OUTPUT
, ‘filetype-1’ or <F11> are pressed.
‘filetype-1’ switches you to a file with the same file name as your .sas file, but with a different extension (.txt by default) and performs ‘refresh’. You can over-ride the default extension; for example in your ~/.emacs or ~/.xemacs/init.el file:
(setq ess-sas-suffix-1 "csv") ; for example
<F9> will prompt you for the name of a permanent SAS dataset near
point to be opened for viewing by PROC FSEDIT
. You can control the
SAS batch command-line with ess-sas-data-view-submit-options
.
For controlling the SAS batch commands, you have the global variables
ess-sas-data-view-libname
and
ess-sas-data-view-fsview-command
as well as the buffer-local
variable ess-sas-data-view-fsview-statement
. If you have your
SAS LIBNAME
defined in ~/autoexec.sas, then the defaults
for these variables should be sufficient.
Similarly, C-<F9> will prompt you for the name of a permanent
SAS dataset near point to be opened for viewing by PROC INSIGHT
.
You can control the SAS batch command-line with
ess-sas-data-view-submit-options
. For controlling the SAS batch
commands, you have the global variables ess-sas-data-view-libname
and ess-sas-data-view-insight-command
as well as the buffer-local
variable ess-sas-data-view-insight-statement
.
<F10> toggles ESS[SAS] mode for .log files which is off by default
(technically, it is SAS-log-mode
, but it looks the same). The syntax
highlighting can be helpful in certain debugging situations, but large
.log files may take a long time to highlight.
<F11> is the same as ‘filetype-1’ except it is .dat by default.
<F12> will prompt you for the name of a GSASFILE
near the point in .log to
be opened for viewing either with emacs or with an external viewer.
Depending on your version of emacs and the operating system you are
using, emacs may support .gif and .jpg files internally. You may need
to change the following variables for your own situation.
ess-sas-graph-view-suffix-regexp
is a regular expression of supported
file types defined via file name extensions.
ess-sas-graph-view-viewer-default
is the default external viewer for
your platform. ess-sas-graph-view-viewer-alist
is an alist of
exceptions to the default; i.e. file types and their associated
viewers which will be used rather than the default viewer.
(setq ess-sas-graph-view-suffix-regexp (concat "[.]\\([eE]?[pP][sS]\\|" "[pP][dD][fF]\\|[gG][iI][fF]\\|[jJ][pP][eE]?[gG]\\|" "[tT][iI][fF][fF]?\\)")) ;; default (setq ess-sas-graph-view-viewer-default "kodakimg") ;; Windows default (setq ess-sas-graph-view-viewer-default "sdtimage") ;; Solaris default (setq ess-sas-graph-view-viewer-alist '(("[eE]?[pP][sS]" . "gv") ("[pP][dD][fF]" . "gv")) ;; default w/ gv
C-<F2> produces US landscape by default, however, it can produce A4 landscape (first line for "global" key mapping, second for "local"):
(global-set-key [(control f2)] 'ess-sas-rtf-a4-landscape) (define-key sas-mode-local-map [(control f2)] 'ess-sas-rtf-a4-landscape)
Inferior ESS (iESS) is the method for interfacing with interactive
statistical processes (programs). iESS[SAS] is what is needed for
interactive SAS programming. iESS[SAS] works best
with the SAS command-line option settings
"-stdio -linesize 80 -noovp -nosyntaxcheck"
(the default of inferior-SAS-args
).
-stdio
required to make the redirection of stdio work-linesize 80
keeps output lines from folding on standard terminals-noovp
prevents error messages from printing 3 times-nosyntaxcheck
permits recovery after syntax errors
To start up iESS[SAS] mode, use:
M-x SAS
The *SAS:1.log* buffer in ESStr
mode corresponds to the file
foo.log in SAS batch usage and to the ‘SAS: LOG’ window in the
SAS Display Manager. All commands submitted to SAS, informative
messages, warnings, and errors appear here.
The *SAS:1.lst* buffer in ESSlst
mode corresponds to the file
foo.lst in SAS batch usage and to the ‘SAS: OUTPUT’ window in the
SAS Display Manager. All printed output appears in this window.
The *SAS:1* buffer exists solely as a communications buffer.
The user should never use this buffer directly.
Files are edited in the foo.sas buffer. The C-c C-r key in
ESS[SAS] is the functional equivalent of bringing a file into the
‘SAS: PROGRAM EDITOR’ window followed by SUBMIT
.
For example, open the file you want to work with.
C-x C-f foo.sas
foo.sas will be in ESS[SAS] mode. Edit as appropriate, and then start up SAS with the cursor in the foo.sas buffer.
M-x SAS
Four buffers will appear on screen:
Buffer | Mode | Description
|
foo.sas | ESS[SAS] | your source file
|
*SAS:1* | iESS[SAS:1] | iESS communication buffer
|
*SAS:1.log* | Shell ESStr [] | SAS log information
|
*SAS:1.lst* | Shell ESSlst [] | SAS listing information
|
Send regions, lines, or the entire file contents to SAS
(regions are most useful: a highlighted region will normally
begin with the keywords DATA
or PROC
and end with
RUN;
), C-c C-r.
Information appears in the log buffer, analysis results in the listing buffer. In case of errors, make the corrections in the foo.sas buffer and resubmit with another C-c C-r.
At the end of the session you may save the log and listing buffers with the usual C-x C-s commands. You will be prompted for a file name. Typically, the names foo.log and foo.lst will be used. You will almost certainly want to edit the saved files before including them in a report. The files are read-only by default. You can make them writable by the emacs command C-x C-q.
At the end of the session, the input file foo.sas will typically have been revised. You can save it. It can be used later as the beginning of another iESS[SAS] session. It can also be used as a batch input file to SAS.
The *SAS:1* buffer is strictly for ESS use. The user should never need to read it or write to it. Refer to the .lst and .log buffers for monitoring output!
Troubleshooting: See iESS(SAS)–Common problems.
-stdio
option.
SAS does not support the -stdio
option on Windows.
(set-file-modes "ess-sas-sh-command" 493)
.
sas
isn't in your executable path; to verify, type
M-: and at the minibuffer prompt ‘Eval:’, type
(executable-find "sas")
sas
on your system calls a shell script. In that case you will need to locate
the real sas
executable and link to it.
You can execute the UNIX command:
find / -name sas -print
Now place a soft link to the real sas
executable in your ~/bin
directory, with for example
cd ~/bin ln -s /usr/local/sas9/sas sas
PATH
environment variable to confirm that
~/bin
appears before the directory in which the sas
shell script appears.
Output from a SAS/GRAPH PROC
can be displayed in a SAS/GRAPH
window for SAS batch on Windows or for both SAS batch and interactive
with XWindows on UNIX. If you need to create graphics files and view
them with <F12>, then include the following (either in
foo.sas or in ~/autoexec.sas):
filename gsasfile 'graphics.ps'; goptions device=ps gsfname=gsasfile gsfmode=append;
PROC PLOT
graphs can be viewed in the listing buffer. You may
wish to control the vertical spacing to allow the entire plot
to be visible on screen, for example:
proc plot; plot a*b / vpos=25; run;
Or you can mark regions with the mouse and submit the code with `submit-region' or paste them into SAS Display Manager.
ESS[BUGS] was originally designed for use with BUGS software. Later, it evolved to support JAGS as a dialect of the BUGS language via ESS[JAGS], however, ESS[JAGS] is documented in the section Help for JAGS. ESS[BUGS] provides 5 features. First, BUGS syntax is described to allow for proper fontification of statements, distributions, functions, commands and comments in BUGS model files, command files and log files. Second, ESS creates templates for the command file from the model file so that a BUGS batch process can be defined by a single file. Third, ESS provides a BUGS batch script that allows ESS to set BUGS batch parameters. Fourth, key sequences are defined to create a command file and submit a BUGS batch process. Lastly, interactive submission of BUGS commands is also supported.
Model files with the .bug extension are edited in ESS[BUGS] mode
if (require 'essd-bugs)
was performed or edited in ESS[JAGS] mode
if (require 'essd-jags)
.
Three keys are bound for your use in ESS[BUGS], F2, C-c C-c and =.
F2 performs the same action as it does in ESS[SAS],
See ESS(SAS)–Function keys for batch processing. C-c C-c performs the
function ess-bugs-next-action
which you will use a lot. Pressing it
in an empty buffer for a model file will produce a template for you. =
inserts the set operator, <-
.
ESS[BUGS] supports "replacement" variables. These variables are
created as part of the template, i.e. with the first press of C-c C-c
in an empty buffer. They are named by all capitals and start
with %
: %N
, %DATA
, %INIT
, %MONITOR
and
%STATS
. When you are
finished editing your model file, pressing C-c C-c will perform
the necessary replacements and build your command file for you.
The %DATA
variable appears in the line data in "%DATA";
. On the
second press of C-c C-c, %DATA
will be replaced by the model file name
except it will have the .dat extension. If your data file is named
something else, then change %DATA
in the template to the appropriate
file name and no replacement will occur.
The %INIT
variable appears in the line inits in "%INIT";
.
On the second press of C-c C-c, %INIT
will be
replaced by the model file name except it will have the .in extension.
If your model will be generating it's own initial values, place a
comment character, #
, at the beginning of the line. Or, if your init
file is named something else, then change %INIT
in the template to the
appropriate file name.
The %N
variable appears in the line const N = 0;#%N
.
Although it is commented, it is still active. Notice that later on in
the template you have the line for (i in 1:N)
. The BUGS
constant N
is the number of rows in your data file. When you
press C-c C-c, the data file is read and the number of lines are
counted (after %DATA
is resolved, if necessary). The number of
lines replace the zero in the const N = 0;
statement.
The %MONITOR
variable appears on a line by itself. Although it
is commented, it is still active. This line is a list of variables
that you want monitored. When you press C-c C-c, the
appropriate statements are created in the command file to monitor the
list of variables. If the line is blank, then the list is populated
with the variables from the var
statement.
The %STATS
variable is similar to the %MONITOR
variable.
It is a list of variables for which summary statistics will be
calculated. When you press C-c C-c, the appropriate statements
will be generated in your command file.
Please note that the %DATA
and %INIT
variables are only
replaced on the second press of C-c C-c, but the actions for
%N
, %MONITOR
and %STATS
are performed on each
press of C-c C-c if you re-visit the model file.
To avoid extension name collision, .bmd is used for BUGS
command files and .jmd for JAGS command files. When you have
finished editing your model file and press C-c C-c, a command
file is created if one does not already exist. However, the command
file was created, it recognizes two "replacement" variables:
%MONITOR
and %STATS
.
Two %MONITOR
variables appears on lines by themselves.
Although they are commented, they are still active. Between them
appears the necessary statements to monitor the list of variables
specified in the model file. The behavior of the %STATS
variable is similar.
When you are finished editing your command file, pressing C-c C-c again will submit your command file as a batch job. BUGS batch scripts are provided for both Unix and DOS in the etc sub-directory of the ESS distribution. The Unix script is backbugs for BUGS major version 0.6 and backbug5 for 0.5. The DOS script is BACKBUGS.BAT for BUGS major version 0.6 only. These scripts allows ESS access to BUGS batch features that are not readily available with the batch scripts that come with BUGS.
To avoid extension name collision, .bog is used for BUGS log files. The BUGS batch script provided with ESS creates the .bog file from the .log file when the batch process completes. If you need to look at the .log file while the batch process is running, it will not appear in ESS[BUGS] mode. You may find F2 useful to refresh the .log if the batch process over-writes or appends it.
ESS[BUGS] was originally designed for use with BUGS software. Later, it evolved to support JAGS as a dialect of the BUGS language via ESS[JAGS]. Since BUGS and JAGS are quite similar, ESS[BUGS] and ESS[JAGS] are necessarily similar. ESS[JAGS] provides 4 features. First, JAGS syntax is described to allow for proper fontification of statements, distributions, functions, commands and comments in JAGS model files, command files and log files. Second, ESS creates templates for the command file from the model file so that a JAGS batch process can be defined by a single file. Third, ESS provides a JAGS batch script that allows ESS to set JAGS batch parameters. Fourth, key sequences are defined to create a command file and submit a JAGS batch process.
Model files with the .bug extension are edited in ESS[BUGS] mode
if (require 'essd-bugs)
was performed or edited in ESS[JAGS] mode
if (require 'essd-jags)
.
Three keys are bound for your use in ESS[BUGS], F2, C-c C-c and =.
F2 performs the same action as it does in ESS[SAS],
See ESS(SAS)–Function keys for batch processing. C-c C-c performs the
function ess-bugs-next-action
which you will use a lot. Pressing it
in an empty buffer for a model file will produce a template for you. =
inserts the set operator, <-
.
ESS[JAGS] does not support "replacement" variables which were part of
ESS[BUGS]. Although, "replacement" variables are an extremely convenient
feature, creating the elisp code for their operation was challenging. So, a
more elisp-ish approach was adopted for ESS[JAGS]: elisp local variables.
These variables are
created as part of the template, i.e. with the first press of C-c C-c
in an empty buffer. For your .bug file, they are named
ess-jags-chains
, ess-jags-monitor
, ess-jags-thin
,
ess-jags-burnin
and ess-jags-update
;
they appear in the Local Variables
section. When you are
finished editing your model file, pressing C-c C-c will perform
the necessary actions to build your command file for you.
The ess-jags-chains
variable is the number of chains that
you want to initialize and sample from; defaults to 1.
The ess-jags-monitor
variable is a list of variables
that you want monitored: encase each variable in double quotes.
When you press C-c C-c, the
appropriate statements are created in the command file to monitor the
list of variables. By default, no variables are explicitly monitored
which means JAGS will implicitly monitor all “default” variables.
The ess-jags-thin
variable is the thinning parameter.
By default, the thinning parameter is set to 1, i.e. no thinning.
The ess-jags-burnin
variable is the number of initial samples
to discard. By default, the burnin parameter is set to 10000.
The ess-jags-update
variable is the number of post-burnin samples
to keep. By default, the update parameter is set to 10000. Both
ess-jags-burnin
and ess-jags-update
are multiplied by
ess-jags-thin
since JAGS does not do it automatically.
To avoid extension name collision, .bmd is used for BUGS
command files and .jmd for JAGS command files. For your
.jmd file, there is only one variable, ess-jags-command
,
in the Local Variables
section. When you have
finished editing your model file and press C-c C-c, a command
file is created if one does not already exist.
When you are finished editing your command file, pressing C-c C-c
again will submit your command file as a batch job.
The ess-jags-command
variable allows you to specify a different
JAGS program to use to run your model; defaults to “jags”.
The .jog extension is used for JAGS log files. You may find F2 useful to refresh the .jog if the batch process over-writes or appends it.
ESS has a few miscellaneous features, which didn't fit anywhere else.
ESS provides Font-Lock (see Using Multiple Typefaces) patterns for Inferior S Mode, S
Mode, and S Transcript Mode buffers.
Syntax highlighting within ESS buffers is controlled by the variable
ess-font-lock-mode
, which by default is true.
Input to inferior ESS processes is also highlighted syntactically if
inferior-ess-font-lock-input
is non-nil (the default).
If you change the value of either of these varibles, you need to restart
emacs for your changes to take effect.
The font-lock patterns are defined in the following variables, which you may modify if desired:
Font-lock patterns for inferior *R* processes. (There is a corresponding
inferior-ess-S-font-lock-keywords
for *S* processes.) The default value highlights prompts, inputs, assignments, output messages, vector and matrix labels, and literals such as ‘NA’ andTRUE
.
Font-lock patterns for ESS R programming mode. (There is a corresponding
ess-S-mode-font-lock-keywords
for S buffers.) The default value highlights function names, literals, assignments, source functions and reserved words.
Emacs and XEmacs have facilities for highlighting the parenthesis matching the parenthesis at point. This feature is very useful when trying to examine which parentheses match each other. This highlighting also indicates when parentheses are not matching. Depending on what version of emacs you use, one of the following should work in your initialisation file:
(paren-set-mode 'paren) ;for XEmacs (show-paren-mode t) ;for Emacs
One of the main features of the S
package is its ability to
generate high-resolution graphics plots, and ESS provides a number of
features for dealing with such plots.
printer()
driverThis is the simplest (and least desirable) method of using graphics
within ESS. S's printer()
device driver produces crude character
based plots which can be contained within the ESS process buffer
itself. To start using character graphics, issue the S command
printer(width=79)
(the width=79
argument prevents Emacs line-wrapping at column
80 on an 80-column terminal. Use a different value for a terminal with
a different number of columns.) Plotting commands do not generate
graphics immediately, but are stored until the show()
command
is issued, which displays the current figure.
Of course, the ideal way to use graphics with ESS is to use a windowing
system. Under X11, this requires that the DISPLAY environment
variable be appropriately set, which may not always be the case within
your Emacs process. ESS provides a facility for setting the value of
DISPLAY before the ESS process is started if the variable
ess-ask-about-display
is non-nil
.
S+6.1 and newer on Windows contains a java library that supports graphics. Send the commands:
library(winjava) java.graph()
to start the graphics driver. This allows you to use ESS for both interaction and graphics within S-PLUS. (Thanks to Tim Hesterberg for this information.)
Imenu is an Emacs tool for providing mode-specific buffer indexes. In some of the ESS editing modes (currently SAS and S), support for Imenu is provided. For example, in S mode buffers, the menubar should display an item called "Imenu-S". Within this menubar you will then be offered bookmarks to particular parts of your source file (such as the starting point of each function definition).
Imenu works by searching your buffer for lines that match what ESS
thinks is the beginning of a suitable entry, e.g. the beginning of a
function definition. To examine the regular expression that ESS uses,
check the value of imenu-generic-expression
. This value is set
by various ESS variables such as ess-imenu-S-generic-expression
.
The R and S editing modes have support for a toolbar. This toolbar provides icons to act as shortcuts for starting new S/R processes, or for evaluating regions of your source buffers. The toolbar should be present if your emacs can display images. See Customization, for ways to change the toolbar.
The Emacs tags facility can be used to navigate around your files containing definitions of S functions. This facility is independent of ESS usage, but is written here since ESS users may wish to take advantage of TAGS facility. Read more about emacs tags in an emacs manual.
Etags, the program that generates the TAGS file, does not yet know the syntax to recognise function definitions in S files. Hence, you will need to provide a regexp that matches your function definitions. Here is an example call (broken over two lines; type as one line) that should be appropriate.
etags --language=none --regex='/\([^ \t]+\)[ \t]*<-[ \t]*function/\1/' *.R
This will find entries in your source file of the form:
some.name <- function
with the function name starting in column 0. Windows users may need to change the single quotes to double quotes.
R version 2.9.0 introduced a front-end script for finding R tags, which calls the ‘rtags()’ function). By default, this script will recursively search the directories for relevant tags in R/C/Rd files. To use this script from the command line, try the following to get started:
R CMD rtags --help
Ess-rdired provides a dired-like buffer for viewing, editing and plotting objects in your current R session. If you are used to using the dired (directory editor) facility in Emacs, this mode gives you similar functionality for R objects.
To get started, first make sure you can load ess-rdired. Add the following to your .emacs and then restart emacs.
(autoload 'ess-rdired "ess-rdired" "View *R* objects in a dired-like buffer." t)
Start an R session with M-x R and then store a few variables, such as:
s <- sin(seq(from=0, to=8*pi, length=100)) x <- c(1, 4, 9) y <- rnorm(20) z <- TRUE
Then use M-x ess-rdired to create a buffer listing the objects in your current environment and display it in a new window:
mode length s numeric 100 x numeric 3 y numeric 20 z logical 1
Type C-h m or ? to get a list of the keybindings for this mode. For example, with your point on the line of a variable, `p' will plot the object, `v' will view it, and `d' will mark the object for deletion (`x' will actually perform the deletion).
ess-display-help-on-object
and list completion
cannot be used while the user is entering a multi-line command. The
only real fix in this situation is to use another ESS process.
ess-eval-
commands can leave point in the ESS process
buffer in the wrong place when point is at the same position as the last
process output. This proves difficult to fix, in general, as we need to
consider all windows with window-point
at the right place.
ess-keep-dump-files
is nil
.
ess-execute
causes ESS
to hang.
options(continue = " ")
) are not automatically detected by ESS.
Hence, for now, the best thing is not to change the continuation prompt.
If you do change the continuation prompt, you will need to change
accordingly the value of inferior-ess-secondary-prompt
in
R-customize-alist
.
Please send bug reports, suggestions etc. to ESS-bugs@stat.math.ethz.ch
The easiest way to do this is within Emacs by typing
M-x ess-submit-bug-report
This also gives the maintainers valuable information about your installation which may help us to identify or even fix the bug.
If Emacs reports an error, backtraces can help us debug the problem. Type "M-x set-variable RET debug-on-error RET t RET". Then run the command that causes the error and you should see a *Backtrace* buffer containing debug information; send us that buffer.
Note that comments, suggestions, words of praise and large cash donations are also more than welcome.
There is a mailing list for discussions and announcements relating to ESS. Join the list by sending an e-mail with "subscribe ess-help" (or "help") in the body to ess-help-request@stat.math.ethz.ch; contributions to the list may be mailed to ess-help@stat.math.ethz.ch. Rest assured, this is a fairly low-volume mailing list.
The purposes of the mailing list include
Emacs is a complex editor with many abilities that we do not have space to describe here. If you have problems with other features of emacs (e.g. printing), there are several sources to consult, including the emacs FAQs (try M-x xemacs-www-faq or M-x view-emacs-FAQ) and EmacsWiki (http://www.emacswiki.org). Please consult them before asking on the mailing list about issues that are not specific to ESS.
ESS can be easily customized to your taste simply by including the appropriate lines in your .emacs file. There are numerous variables which affect the behavior of ESS in certain situations which can be modified to your liking. Keybindings may be set or changed to your preferences, and for per-buffer customizations hooks are also available.
Most of these variables can be viewed and set using the Custom facility within Emacs. Type M-x customize-group RET ess RET to see all the ESS variables that can be customized. Variables are grouped by subject to make it easy to find related variables.
attach()
: Hot keysbackward-kill-word
: Command-line editingcomint-backward-matching-input
: Process buffer motioncomint-bol
: Command-line editingcomint-copy-old-input
: Transcript resubmitcomint-delimiter-argument-list
: History expansioncomint-dynamic-complete
: Completioncomint-forward-matching-input
: Process buffer motioncomint-input-ring-size
: Command Historycomint-interrupt-subjob
: Othercomint-kill-input
: Command-line editingcomint-kill-output
: Last commandcomint-next-input
: Command Historycomint-next-input
: Process buffer motioncomint-next-matching-input
: Command Historycomint-next-matching-input-from-input
: Command Historycomint-previous-input
: Command Historycomint-previous-input
: Process buffer motioncomint-previous-matching-input
: Command Historycomint-previous-matching-input-from-input
: Command Historycomint-show-maximum-output
: Last commandcomint-show-output
: Last commandcomint-stop-subjob
: Othercomment-column
: Indentingdump()
: Edit bufferess-abort
: Otheress-ask-about-display
: X11ess-ask-about-transfile
: Saving transcriptsess-ask-about-transfile
: Customizing startupess-ask-for-ess-directory
: Customizing startupess-beginning-of-function
: Other edit buffer commandsess-change-sp-regexp
: Completion detailsess-cleanup
: Helpess-cleanup
: Hot keysess-delete-dump-files
: Source Filesess-describe-help-mode
: Helpess-directory
: Source Directoriesess-display-help-on-object
: Helpess-dump-filename-template
: Source Directoriesess-dump-object-into-edit-buffer
: Edit bufferess-dump-object-into-edit-buffer
: OtherESS-elsewhere
: ESS processes on Remote Computersess-end-of-function
: Other edit buffer commandsess-eval-buffer
: Evaluating codeess-eval-function
: Evaluating codeess-eval-function-and-go
: Evaluating codeess-eval-line
: Evaluating codeess-eval-line-and-go
: Evaluating codeess-eval-line-and-step
: Helpess-eval-line-and-step
: Evaluating codeess-eval-region
: Helpess-eval-region
: Evaluating codeess-eval-region-and-go
: Evaluating codeess-eval-visibly-p
: Evaluating codeess-execute
: Hot keysess-execute-attach
: Hot keysess-execute-in-process-buffer
: Hot keysess-execute-in-tb
: Evaluating codeess-execute-objects
: Hot keysess-execute-search
: Hot keysess-fancy-comments
: Indentingess-function-template
: Edit bufferess-keep-dump-files
: Source Filesess-list-object-completions
: Completioness-load-file
: Loadingess-load-file
: Hot keysess-parse-errors
: Error Checkingess-parse-errors
: Hot keysess-quit
: Helpess-quit
: Otheress-R-mode-font-lock-keywords
: Highlightingess-remote
: ESS processes on Remote Computersess-request-a-process
: Multiple ESS processesess-resynch
: Completion detailsess-search-list
: Source Directoriesess-skip-to-help-section
: Helpess-skip-to-next-section
: Helpess-skip-to-previous-section
: Helpess-source-directory
: Source Directoriesess-submit-bug-report
: Reporting Bugsess-switch-to-end-of-ESS
: Helpess-switch-to-end-of-ESS
: Other edit buffer commandsess-switch-to-ESS
: Other edit buffer commandsess-transcript-clean-region
: Saving transcriptsess-transcript-copy-command
: Resubmitess-transcript-send-command
: Resubmitess-transcript-send-command-and-move
: Transcript resubmitexit()
: Hot keysinferior-ess-program
: Customizing startupinferior-ess-R-font-lock-keywords
: Highlightinginferior-ess-send-input
: Transcript resubmitinferior-ess-send-input
: Command-line editingobjects()
: Hot keysprinter()
: printerq()
: Hot keysS
: Starting upS+elsewhere
: ESS processes on Remote Computerssearch()
: Hot keyssearch()
: Completionsource()
: Evaluating codesource()
: LoadingSTERM
: Statistical Process running in ESS?[1] The variable ess-change-sp-regexp
is a regular
expression matching commands which change the search list. You will
need to modify this variable if you have defined custom commands (other
than attach
, detach
, collection
or library
)
which modify the search list.