
We now discuss installation, which might happen under Unix or
Microsoft Windows.  First, we discuss Unix installation.  
@xref{Unix installation}.

For Microsoft Windows Installation please skip to the
@xref{Microsoft Windows installation}.

@node Unix installation, Microsoft Windows installation, , Installation
@comment  node-name,  next,  previous,  up
@section Unix installation

@enumerate 

@item
cd to a directory where you want to install ESS, creating it if necessary.
This directory will be referred to below as ESSDIR.  
@comment It will contain,
@comment at the end, the tar file @file{ess-VERSION.tar.gz}, and a directory for
@comment the ESS source, which will be termed "the ESS-VERSION source directory".
@comment Note that the .elc files may be installed elsewhere (as specified in the
@comment Makefile) if desired.

@item
Retrieve the latest version from 
@uref{http://ess.r-project.org/downloads/ess, ESS downloads area}
to ESSDIR.

@item
Decompress/unarchive the files from the disribution.
@example
gunzip ess-VERSION.tar.gz
tar xvf ess-VERSION.tar
@end example
@display
(or: @code{gunzip < ess-VERSION.tar.gz | tar xvf -} ).
(or using GNU tar:  @code{tar zxvf ess-VERSION.tar.gz}).
@end display

The @code{tar} command will create the subdirectory ess-VERSION and unarchive
the files there.

@comment If you are using GNU Emacs 19.29, decompress/unarchive
@comment @file{ESSDIR/ess-VERSION/lisp/19.29.tar.gz}, 
@comment read @file{ESSDIR/ess-VERSION/lisp/19.29/README}, follow the instructions
@comment and you might be able to get ESS to work.  
@comment @emph{Please note that GNU Emacs 19.29 is no longer supported}.
@comment For a list of supported versions of emacs, see @xref{Requirements}.

@item
Edit the file @file{ESSDIR/ess-VERSION/lisp/ess-site.el} as explained in the 
comments section of that file.  
@comment Installations that are using ESS only for S-Plus
@comment 6.x will probably not need to make any changes.  Installations that also
@comment have one or more of (S4, S+3/4/5/6/7, R, SAS, BUGS, XLispStat, Stata)
@comment may need to uncomment corresponding lines in @file{ESSDIR/ess-VERSION/lisp/ess-site.el}.

@item
 Add the line
@example
(load "ESSDIR/ess-VERSION/lisp/ess-site")
@end example
to your user or system installation file
(GNU Emacs uses @file{$HOME/.emacs} and XEmacs uses @file{$HOME/.xemacs/init.el}
for the user initialization file.  GNU Emacs uses default.el or site-init.el and 
XEmacs uses site-start.el for the system installation file). 

Alternatively, if ess-site.el is in your current Lisp path, you can do:
@example
(require 'ess-site)
@end example
to configure emacs for ESS.

@item
That's it!  If you are installing just a local copy of ESS for yourself,
ESS is now ready to be used.  (The remaining step below is for
advanced installation.)  To edit statistical programs, load the files
with the requiste extensions (".sas" for SAS, ".S" for S-PLUS, ".R" for
R, and ".lsp" for XLispStat).  To start a statistical process within
Emacs, such as R, type @code{M-x R}.

@c @item
@c (OPTIONAL) If you are running S-PLUS or R, you might consider
@c installing the database files.  From within emacs, @code{C-x d} to the
@c directory containing ESS.  Now:
@c @example
@c M-x S+6
@c @end example
@c to get S running.  Once you see the SPLUS prompt, do:
@c @example
@c M-x ess-create-object-name-db
@c @end example
@c (this will create the file @file{ess-sp6-namedb.el}; if it isn't in the
@c ESS directory, move it there).

@c Then, completions will be autoloaded and will not be regenerated for
@c every session.

@c For R, do the same, using
@c @example
@c M-x R
@c @end example
@c and then @code{M-x ess-create-object-name-db} creating
@c @file{ess-r-namedb.el}; if it isn't in the ESS directory, move it there).

@item
@b{(OPTIONAL) READ THIS ITEM THOROUGHLY BEFORE STARTING}:

If you want to place the compiled files in other locations edit the LISPDIR and INFODIR
entries in @file{Makeconf} in the ESSDIR/ess-VERSION directory (if you are using XEmacs, 
then you also need to edit the EMACS entry as follows:  EMACS=xemacs).

You can compile those files by:
@example
make all
@end example

When that completes successfully, install the compiled files:
@example
make install
@end example

This will install the compiled info files and lisp files.  If you are an
XEmacs user, then you should be done.  If not, then you may have to
edit/create the file @file{dir} that is found in the directory specified
by @code{INFODIR}: see the sample @file{dir} in ESSDIR/ess-VERSION/doc/info.
If @file{dir} does not exist in @code{INFODIR}, then the sample
@file{dir} will be installed.

@emph{Note:} ESS can be installed for XEmacs as an XEmacs package
much more easily than what has been described anywhere above.  However,
the latest ESS version will not be available at the same time as an
XEmacs package; generally, it can take weeks or months to appear in the
latter format.  For more information on installing ESS as an XEmacs
package see @uref{http://www.xemacs.org/Documentation/packageGuide.html, Quickstart Package Guide}.

@comment An alternative, if you are running XEmacs and have access to the
@comment XEmacs system directories, would be to place the directory in the
@comment site-lisp directory, and simply type @code{make all} (and copy the
@comment documentation as appropriate).
@comment 
@comment For GNU Emacs, you would still have to move the files into the top level
@comment site-lisp directory.

@end enumerate

@c >>>> FIXME (see comment in ess.texi): error in ``makeinfo readme.texi''
@c @node Microsoft Windows installation, , Unix installation, Installation
@node Microsoft Windows installation, Requirements, Unix installation, Installation
@comment  node-name,  next,  previous,  up
@section Microsoft Windows installation

For @b{Microsoft Windows installation}, please follow the next steps:
(see separate instructions above for UNIX @xref{Unix installation}.

@enumerate

@item
cd to a directory where you keep emacs lisp files, or create a new
directory (for example, @file{c:\emacs\}) to hold the distribution.  This
directory will be referred to below as "the ESS distribution
directory".  It will contain, at the end, either the tar file
@file{ess-VERSION.tar.gz} or the zip file @file{ess-VERSION.zip}, and a
directory 
for the ESS source, which will be termed "the ESS-VERSION source
directory".

@item
Retrieve the compressed tar file @file{ess-VERSION.tar.gz} or the
zipped file @file{ess-VERSION.zip} from one of the FTP or WWW
archive sites 
via FTP (or HTTP).  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.

@item
Copy @file{ess-VERSION.tar.gz} to the location where you want the
ess-VERSION directory, for example to
@file{c:\emacs\ess-VERSION.tar.gz}, and cd there.  For example,

@example
cd c:\emacs
@end example

Extract the files from the distribution, which will unpack
into a subdirectory, @file{ess-VERSION}.
@example
gunzip ess-VERSION.tar.gz
tar xvf ess-VERSION.tar
(or: @code{gunzip < ess-VERSION.tar.gz | tar xvf -} ).
(or: from the zip file: @code{unzip ess-VERSION.zip})
@end example

The @code{tar} command will extract files into the current directory.

Do not create @file{ess-VERSION} yourself, or you will get an extra level
of depth to your directory structure.

@item
Windows users will usually be able to use the `lisp/ess-site.el'
as distributed.  Only rarely will changes be needed.

@item
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
@file{c:\autoexec.bat} 
file:
@example
path=%PATH%;c:\progra~1\spls2000\cmd
@end example
On Windows NT/2000/XP, add the directories to the PATH using the
@code{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
@code{progra~1} and not the long version with embedded blanks.  Use
backslashes "\".

@item
Add the line 
@example        
(load "/PATH/ess-site")
@end example
to your .emacs (or _emacs) file (or default.el or site-init.el, for
a site-wide installation).  Replace @code{/PATH} above with the
value of ess-lisp-directory as defined in @file{ess-site.el}.  Use
forwardslashes @code{/}.
(GNU Emacs uses the filename @file{%HOME%/.emacs} and
XEmacs uses the filename @file{%HOME%/.xemacs/init.el}
for the initialization file.)

@item
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).

@item
To run statistical processes under emacs:

To start the S-PLUS [67].x GUI from ESS under emacs:
@example
M-x S
(or @code{M-x S+6}).
@end example
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,
@file{myfile.s}) to the S-PLUS Commands Window with the 
@code{C-c C-n} or @code{C-c C-r} keys.
(If you are still using S-PLUS 4.x or 2000, then use @code{M-x S+4}.)

To start an S-PLUS [67].x session inside an emacs buffer---and
without the S-PLUS GUI:
@example
M-x Sqpe
(or @code{M-x Sqpe+6}).
@end example
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, @file{myfile.s}) to the *S+6* buffer with the
@code{C-c C-n} or @code{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:
@example
library(winjava)
java.graph()
@end example
Graphs can be saved from the @code{java.graph} device
in several formats, but not PostScript.   If you
need a PostScript file you will need to open a separate
@code{postscript} device.
(If you are still using S-PLUS 4.x or 2000, then use @code{M-x Sqpe+4}.)

To connect to an already running S-PLUS GUI (started, for example,
from the S-PLUS icon):
@example
M-x S+6-existing
@end example
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,
@file{myfile.s}) to the S-PLUS Commands Window with the 
@code{C-c C-n} or @code{C-c C-r} keys.
(If you are still using S-PLUS 4.x or 2000, then use @code{M-x S+4-existing}.)

If you wish to run R, you can start it with:
@example
M-x R
@end example

XLispStat can not currently be run with
@example
M-x XLS
@end example
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.

@comment SAS for Windows uses the batch access with function keys that is
@comment described in 
@comment @file{doc/README.SAS}.
@comment @xref{ESS(SAS)--MS Windows}.
@comment The user can also edit SAS files
@comment in an @code{ESS[SAS]} buffer and than manually copy and paste them into
@comment an Editor window in the SAS Display Manager.
@comment 
@comment For Windows, inferior SAS in an @code{iESS[SAS]} buffer does not work
@comment on the local machine.  It does work over a network connection to
@comment SAS running on a remote Unix computer.
@comment 
@comment Reason:  we use ddeclient to interface with programs and SAS doesn't
@comment provide the corresponding ddeserver capability.

@c @item
@c (OPTIONAL) If you are running Sqpe or R, you might consider
@c installing the database files.  From within emacs, @code{C-x d} to
@c the   directory containing ESS.  Now:
@c @example
@c M-x Sqpe+6
@c @end example
@c to get S running.  Once you see the SPLUS prompt, do:
@c @example
@c M-x ess-create-object-name-db
@c @end example
@c (this will create the file @file{ess-s+6-namedb.el}; if it isn't in the
@c ESS directory, move it there).

@c Then, completions will be autoloaded and will not be regenerated
@c for every session.

@c For R, do the same, using
@c @example
@c M-x R
@c @end example
@c and then @code{M-x ess-create-object-name-db} creating
@c @file{ess-r-namedb.el}; if it isn't in the ESS directory, move it
@c there).

@item That's it!

@end enumerate
@comment Requirements duplicated?
@comment @node Requirements, , Microsoft Windows installation, Installation
@comment  node-name,  next,  previous,  up
@comment @section Requirements
@comment @include requires.texi
