ESS[SAS]: somebody forgot about the SUM statement (probably me)
[ess.git] / doc / help-s.texi
blob8bab328ffedaeca5cc0e1dd6b63799dd7ca0e678
1 @node ESS(S)--Editing files, iESS(S)--Inferior ESS processes, , ESS for the S family
2 @comment  node-name,  next,  previous,  up -- don't use @ESS ..
3 @section ESS[S]--Editing files
5 @ESS{[S]} is the mode for editing S language files.  This mode handles:
7 @itemize @minus
8 @item
9  proper indenting, generated by both [Tab] and [Return].
10 @item
11  color and font choices based on syntax.
12 @item
13  ability to send the contents of an entire buffer, a highlighted
14   region, an S function, or a single line to an inferior S process, if
15   one is currently running.
16 @item
17  ability to switch between processes which would be the target of the
18   buffer (for the above).
19 @item
20  The ability to request help from an S process for variables and
21   functions, and to have the results sent into a separate buffer.
22 @item
23  completion of object names and file names.
24 @end itemize
26 @ESS{[S]} mode should be automatically turned on when loading a file with
27 the suffices found in ess-site (*.R, *.S, *.s, etc).  However, one
28 will have to start up an inferior process to take advantage of the
29 interactive features.
31 @node iESS(S)--Inferior ESS processes, ESS-help--assistance with viewing help, ESS(S)--Editing files, ESS for the S family
32 @comment  node-name,  next,  previous,  up
33 @section iESS[S]--Inferior ESS processes
34 iESS (inferior ESS) is the mode for interfacing with active
35 statistical processes (programs).  This mode handles:
37 @itemize @minus
38 @item
39  proper indenting, generated by both [Tab] and [Return].
40 @item
41  color and font highlighting based on syntax.
42 @item
43  ability to resubmit the contents of a multi-line command
44  to the executing process with a single keystroke [RET].
45 @item
46  The ability to request help from the current process for variables
47  and functions, and to have the results sent into a separate buffer.
48 @item
49  completion of object names and file names.
50 @item
51  interactive history mechanism.
52 @item
53  transcript recording and editing.
54 @end itemize
56 To start up iESS mode, use:
57 @example
58    M-x S+3
59    M-x S4
60    M-x S+5
61    M-x S+6
62    M-x R
63 @end example
65 (for S-PLUS 3.x, S4, S+5, S+6 or S+7, and R, respectively.  This assumes that
66 you have access to each).  Usually the site will have defined one of
67 these programs (by default S+6) to the simpler name:
69    M-x S
71 In the (rare) case that you wish to pass command line arguments to the
72 starting S+6 process, set the variable @code{inferior-Splus-args}.
74 Note that R has some extremely useful command line arguments.  For
75 example, @code{--vanilla} will ensure R starts up without loading in any init
76 files.  To enter a command line argument, call R using a "prefix
77 argument", by
79    C-u M-x R
81 and when ESS prompts for "Starting Args ? ", enter (for example):
83    @code{--vanilla}
85 Then that R process will be started up using @code{R --vanilla}.  If you
86 wish to always call R with certain arguments, set the variable
87 @code{inferior-R-args} accordingly.
89 @comment Menubar access to other versions of R and Sqpe
91 If you have other versions of R or S-Plus available on the system, ESS
92 is also able to start those versions.  How this works depend on which OS
93 you are using:
96 R on Unix systems:
97 If you have "R-1.8.1" on
98 your `exec-path', it can be started using @kbd{M-x R-1.8.1}.  By
99 default, ESS will find versions of R beginning "R-1" or "R-2".  If your
100 versions of R are called other names, consider renaming them with a
101 symbolic link or change the variable @code{ess-r-versions}.  To see
102 which defuns have been created for starting different versions of R,
103 type @kbd{M-x R-} and then hit [Tab].  You will then see if any defuns
104 for particular versions of R have been created.  These other versions of
105 R can also be started from the "ESS->Start Process->Other" menu.
107 R on Windows systems:
108 If you have "rw1081" on
109 your `exec-path', it can be started using @kbd{M-x rw1081}.  By
110 default, ESS will find versions of R located in directories
111 parallel to the version of R in your @code{PATH}.  If your
112 versions of R are called other names, you will need to change the variable
113 @code{ess-rterm-versions}.  To see
114 which defuns have been created for starting different versions of R,
115 type @kbd{M-x rw} and then hit [Tab].  You will then see if any defuns
116 for particular versions of R have been created.  These other versions of
117 R can also be started from the "ESS->Start Process->Other" menu.
119 Once ESS has found these extra versions of R, it will then create a new
120 defun, called @kbd{M-x R-newest}, which will call the newest version of
121 R that it found.  (ESS examines the date in the first line of
122 information from @code{R --version} to determine which is newest.)
124 S on Unix systems: If you have "Splus7" on your `exec-path', it can be
125 started using @kbd{M-x Splus7}.  By default, ESS will find all
126 executables beginning "Splus" on your path.  If your versions of S are
127 called other names, consider renaming them with a symbolic link or
128 change the variable @code{ess-s-versions}.  To see which defuns have
129 been created for starting different versions of Splus, type @kbd{M-x
130 Splus} and then hit [Tab].  You will then see if any defuns for
131 particular versions of Splus have been created.  These other versions of
132 Splus can also be started from the "ESS->Start Process->Other" menu.
134 A second mechanim is also available for running other versions of Splus.
135 The variable @code{ess-s-versions-list} is a list of lists; each sublist
136 should be of the form: (DEFUN-NAME PATH ARGS).  DEFUN-NAME is the name
137 of the new emacs function you wish to create to start the new S process;
138 PATH is the full path to the version of S you want to run; ARGS is an
139 optional string of command-line arguments to pass to the S process.
140 Here is an example setting:
141 @example
142 (setq ess-s-versions-list 
143       '( ("Splus64" "/usr/local/bin/Splus64")
144          ("Splus64-j" "/usr/local/bin/Splus64" "-j")))
145 @end example
146 which will then allow you to do @kbd{M-x Splus64-j} to start  Splus64
147 with the corresponding command line arguments.
150 If you change the value of either @code{ess-s-versions} or
151 @code{ess-s-versions-list}, you should put them in your .emacs before
152 ess-site is loaded, since the new emacs functions are created when ESS
153 is loaded.
158 Sqpe (S-Plus running inside an emacs buffer) on Windows systems:
159 If you have an older version of S-Plus (S-Plus 6.1 for example) on your system,
160 ir can be started inside an emacs buffer with @kbd{M-x splus61}.  By
161 default, ESS will find versions of S-Plus located in the installation
162 directories that Insightful uses by default.  If your
163 versions of S-Plus are anywhere else, you will need to change the variable
164 @code{ess-SHOME-versions}.  To see
165 which defuns have been created for starting different versions of S-Plus,
166 type @kbd{M-x spl} and then hit [Tab].  You will then see if any defuns
167 for particular versions of S-Plus have been created.  These other versions of
168 S-Plus can also be started from the "ESS->Start Process->Other" menu.
171 @node ESS-help--assistance with viewing help, Philosophies for using ESS(S),iESS(S)--Inferior ESS processes,ESS for the S family
172 @comment  node-name,  next,  previous,  up
173 @section ESS-help--assistance with viewing help
175 ESS has built-in facilities for viewing help files from S.  @xref{Help}.
178 @node Philosophies for using ESS(S), Scenarios for use (possibilities--based on actual usage), ESS-help--assistance with viewing help, ESS for the S family
179 @section Philosophies for using ESS[S]
181 The first is preferred, and configured for.  The second one can be
182 retrieved again, by changing emacs variables.
184 1: (preferred by the current group of developers):  The source code is
185    real.  The objects are realizations of the source code.  Source
186    for EVERY user modified object is placed in a particular directory
187    or directories, for later editing and retrieval.
189 2: (older version): S objects are real.  Source code is a temporary
190    realization of the objects.  Dumped buffers should not be saved.
191    _We_strongly_discourage_this_approach_.  However, if you insist,
192    add the following lines to your .emacs file:
193 @example
194 (setq ess-keep-dump-files 'nil)
195 (setq ess-delete-dump-files t)
196 (setq ess-mode-silently-save nil)
197 @end example
198 The second saves a small amount of disk space.  The first allows for
199 better portability as well as external version control for code.
201 @node Scenarios for use (possibilities--based on actual usage), Customization Examples and Solutions to Problems, Philosophies for using ESS(S),ESS for the S family
202 @section Scenarios for use (possibilities--based on actual usage)
204 We present some basic suggestions for using ESS to interact with S.
205 These are just a subset of approaches, many better approaches are
206 possible.  Contributions of examples of how you work with ESS are
207 appreciated (especially since it helps us determine priorities on
208 future enhancements)! (comments as to what should be happening are
209 prefixed by "##").
210 @display
211 1:  ##    Data Analysis Example (source code is real)
212     ## Load the file you want to work with
213     C-x C-f myfile.s
215     ## Edit as appropriate, and then start up S-PLUS 3.x
216     M-x S+3
218     ## A new buffer *S+3:1* will appear.  Splus will have been started
219     ## in this buffer.  The buffer is in iESS [S+3:1] mode.
221     ## Split the screen and go back to the file editing buffer.
222     C-x 2 C-x b myfile.s
224     ## Send regions, lines, or the entire file contents to S-PLUS.  For regions,
225     ## highlight a region with keystrokes or mouse and then send with:
226     C-c C-r
228     ## Re-edit myfile.s as necessary to correct any difficulties.  Add
229     ## new commands here.  Send them to S by region with C-c C-r, or
230     ## one line at a time with C-c C-n.
232     ## Save the revised myfile.s with C-x C-s.
234     ## Save the entire *S+3:1* interaction buffer with C-c C-s.  You
235     ## will be prompted for a file name.  The recommended name is
236     ## myfile.St.  With the *.St suffix, the file will come up in ESS
237     ## Transcript mode the next time it is accessed from Emacs.
241 2:  ## Program revision example (source code is real)
243     ## Start up S-PLUS 3.x in a process buffer (this will be *S+3:1*)
244     M-x S+3
246     ## Load the file you want to work with
247     C-x C-f myfile.s
249     ## edit program, functions, and code in myfile.s, and send revised
250     ## functions to S when ready with
251     C-c C-f
252     ## or highlighted regions with
253     C-c C-r
254     ## or individual lines with
255     C-c C-n
256     ## or load the entire buffer with
257     C-c C-l
259     ## save the revised myfile.s when you have finished
260     C-c C-s
264 3:  ## Program revision example (S object is real)
266     ## Start up S-PLUS 3.x in a process buffer (this will be *S+3:1*)
267     M-x S+3
269     ## Dump an existing S object my.function into a buffer to work with
270     C-c C-d my.function
271     ## a new buffer named yourloginname.my.function.S will be created with
272     ## an editable copy of the object.  The buffer is associated with the
273     ## pathname /tmp/yourloginname.my.function.S and will amlost certainly not
274     ## exist after you log off.
276     ## enter program, functions, and code into work buffer, and send
277     ## entire contents to S-PLUS when ready
278     C-c C-b
280     ## Go to *S+3:1* buffer, which is the process buffer, and examine
281     ## the results.
282     C-c C-y
283     ## The sequence C-c C-y is a shortcut for:  C-x b *S+3:1*
285     ## Return to the work buffer (may/may not be prefixed)
286     C-x C-b yourloginname.my.function.S
287     ## Fix the function that didn't work, and resubmit by placing the
288     ## cursor somewhere in the function and
289     C-c C-f
290     ## Or you could've selected a region (using the mouse, or keyboard
291     ## via setting point/mark) and
292     C-c C-r
293     ## Or you could step through, line by line, using
294     C-c C-n
295     ## Or just send a single line (without moving to the next) using
296     C-c C-j
297     ## To fix that error in syntax for the "rchisq" command, get help
298     ## by
299     C-c C-v rchisq
302 4:    Data Analysis (S object is real)
303     ## Start up S-PLUS 3.x, in a process buffer (this will be *S+3:1*)
304     M-x S+3
306     ## Work in the process buffer.  When you find an object that needs
307     ## to be changed (this could be a data frame, or a variable, or a
308     ## function), dump it to a buffer:
309     C-c C-d my.cool.function
311     ## Edit the function as appropriate, and dump back in to the
312     ## process buffer
313     C-c C-b
315     ## Return to the S-PLUS process buffer
316     C-c C-y
317     ## Continue working.
319     ## When you need help, use
320     C-c C-v rchisq
321     ## instead of entering:   help("rchisq")
322 @end display
325 @node Customization Examples and Solutions to Problems,  , Scenarios for use (possibilities--based on actual usage),ESS for the S family
326 @section Customization Examples and Solutions to Problems
328 1. Suppose that you are primarily an SPLUS 3.4 user, occasionally
329    using S version 4, and sick and tired of the buffer-name *S+3*
330    we've stuck you with.  Simply edit the "ess-dialect" alist entry in
331    the essd-sp3.el and essd-s4.el files to be "S" instead of "S4" and
332    "S+3".  This will ensure that all the inferior process buffer names
333    are "*S*".
335 2. Suppose that you WANT to have the first buffer name indexed by
336    ":1", in the same manner as your S-PLUS processes 2,3,4, and 5 (for
337    you heavy simulation people).  Then uncomment the line in ess-site
338    (or add after your (require 'ess-site) or (load "ess-site") command
339     in your .emacs file, the line:
340 @example
341 (setq ess-plain-first-buffername nil)
342 @end example
343    )
345 3. Fontlocking sometimes fails to behave nicely upon errors.  When
346    Splus dumps, a mis-matched "  (double-quote) can result in the
347    wrong font-lock face being used for the remainder of the buffer.
349    Solution: add a " at the end of the "Dumped..." statement, to
350    revert the font-lock face back to normal.