Unix installation
=================

 1. cd to a directory where you keep emacs lisp files, or create a new directory (for example, $HOME/ess) to hold the distribution. This directory will be referred to below as "the ESS distribution directory".

     Note for XEmacs packages: ESS is no longer available as an XEmacs package. But, you can still install ESS into the XEmacs package system by choosing ESSDIR=PREFIX/lib/xemacs/site-packages. ESS requires that the XEmacs sumo tarball (all XEmacs packages combined) also be installed.  For information on installing XEmacs packages, follow this link: Quickstart Package Guide (http://www.xemacs.org/Documentation/packageGuide.html).

 2. Retrieve the latest version from ESS downloads area (http://ess.r-project.org/downloads/ess) to ESSDIR.

 3. Extract the files from the disribution.

          If you are using GNU tar, tar zxf ess-VERSION.tgz.
          Otherwise, gunzip < ess-VERSION.tgz | tar xf -,

     The tar command will create the subdirectory ess-VERSION and install the files there.

 4. Edit the file ESSDIR/ess-VERSION/lisp/ess-site.el as explained in the comments section of that file.

 5. If you are using GNU Emacs add the line

          (load "ESSDIR/ess-VERSION/lisp/ess-site")

     to $HOME/.emacs.  For XEmacs, if you followed the XEmacs package system installation advice, add the line

          (require 'ess-site)

     to $HOME/.xemacs/init.el.  Otherwise, for XEmacs, add the line

          (load "ESSDIR/ess-VERSION/lisp/ess-site")

     to $HOME/.xemacs/init.el.

 6. That's it!  ESS is now ready to use.  (The remaining step below is only for a custom installation.)  To edit statistical programs, just open files with the requisite extensions (.R for R, .sas for SAS, .bug for BUGS, etc.).  To start a statistical process within emacs, such as R, type M-x R.

 7. (OPTIONAL) READ THIS ITEM THOROUGHLY BEFORE STARTING:

     If you want to place the compiled files in other locations edit the LISPDIR, INFODIR and ETCDIR entries in Section 1 of Makeconf in the ESSDIR/ess-VERSION directory (if you are using XEmacs, then uncomment the XEmacs subsection in Section 1).

     You can compile those files by:

          make all

     When that completes successfully, install the compiled files:

          make install

Microsoft Windows installation
==============================

For Microsoft Windows installation, please follow the next steps.

 1. cd to a directory where you keep emacs lisp files, or create a new directory (for example, c:\ess\) to hold the distribution. This directory will be referred to below as "the ESS distribution directory".

     Note for XEmacs packages: ESS is no longer available as an XEmacs package. But, you can still install ESS into the XEmacs package system by choosing ESSDIR=PREFIX\XEmacs\site-packages.  ESS requires that the XEmacs sumo tarball (all XEmacs packages combined) also be installed.  For information on installing XEmacs packages, follow this link: Quickstart Package Guide (http://www.xemacs.org/Documentation/packageGuide.html).

 2. Retrieve the latest zip file (ess-VERSION.zip) from ESS downloads area (http://ess.r-project.org/downloads/ess) and store it in the ESS distribution directory.  Be aware that http browsers on Windows frequently change the "." and "-" characters in filenames to other punctuation.  Please change the names back to their original form.

 3. Extract all the files from ess-VERSION.zip into the ESS distribution directory as c:\ess\ess-VERSION\.  (It is possible to unpack the zip archive in Windows Explorer by double clicking on the folder; you should then see a new folder called ess-VERSION. Drag that folder into your ESS distribution directory.)

 4. If you are using GNU Emacs add the line

          (load "ESSDIR/ess-VERSION/lisp/ess-site")

     to %HOME%\.emacs.  For XEmacs, if you followed the XEmacs package system installation advice, add the line

          (require 'ess-site)

     to %HOME%\.xemacs\init.el.  Otherwise, for XEmacs, add the line

          (load "ESSDIR/ess-VERSION/lisp/ess-site")

     to %HOME%\.xemacs\init.el. Note: Both GNU Emacs and XEmacs require that the HOME environment variable be set on your system, otherwise, your initialization file will not be utilized, and therefore, ESS will not work.

     After saving your initialization file, ESS is now installed.  Start a new emacs and 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.

 5. 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 9x, add lines similar to the following to your c:\autoexec.bat file:

          path=%PATH%;c:\progra~1\insightful\splus70\cmd

     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.  Use backslashes "\".

     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) to their %HOME%\.emacs or %HOME%\.xemacs\init.el file:

          (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:

      1. If you use Cygwin bash as your primary shell, then

               M-x S
               (or M-x S+6).

      2. If you use the MSDOS prompt window as your primary shell, then

               M-x S+6-msdos

     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 start the S-PLUS GUI.  There will be slight delay during which emacs is temporarily frozen.  ESS will arrange for communication with the 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 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.

 6. That's it!