<html lang="en"> <head> <title>ESS -- Emacs Speaks Statistics</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="ESS -- Emacs Speaks Statistics"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="top" href="#Top"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } html { margin: 0px; padding: 0px; border-top: 1.4em #000033 solid; font-size: 12px; background-repeat: no-repeat; background-attachment: fixed; background-position: top left; background-color: white; } body { margin: 0px; padding: 0px; font-family: "Trebuchet MS", Arial, sans-serif; color: #171717; line-height: 1.45; /* something smart Eric Meyer said: no unit here */ text-align: justify; width: 40em; padding-left: 15em; padding-right: 2em; border-right: 1px #000033 dotted; } h1 { padding: 2em 1em 2em 1em; font-size: 2em; color: white; text-align: right; margin-left: -10em; margin-top: 0em; margin-right: -1em; background-image: url(../images/logoESS.gif); background-position: left 25%; -o-background-size: 100% auto; background-size: 100% auto; background-origin: content; border-bottom: 0.4em #000033 solid; border-left: 0.1em #000033 solid; text-transform: uppercase; text-shadow: white 0px 0px 10px, black 3px 3px 5px; } h2 { font-size: 1.4em; border-left: 0.6em black solid; padding-left: 0.3em; border-bottom: 1px black solid; padding-bottom: 0.1em; margin-top: 1.5em; letter-spacing: 0.1em; } h3 { margin-bottom: 0em; } h2,h3 { clear: both; } h1 span { font-size: 0.7em; color: #EFEFEF; } h2 span { font-size: 0.7em; color: gray; } h2[id]:hover::after, h3[id]:hover::after { content: "#" attr(id); float:right; font-size:0.7em; /*line-height:2em;*/ color: maroon; padding-left: 1em;} p { margin-top: 0px; margin-bottom: 0.5em;} dt { font-weight: bold; margin: 10px 0px 2px 0px; padding: 2px 0px; border-top: 1px black solid; border-bottom: 1px black solid; text-indent: 1em; letter-spacing: 0.1em; position: relative; } dd + dd { margin-top: 0.7em; } table { font-size: inherit; } /* so that the font-size is inherited into table */ small { margin-top: 2em; display:block; clear: both; } pre { padding: 0.5em; border: 1px gray solid; overflow:auto; background-color: #EFEFEF; } kbd { border: 2px gray outset; padding: 0em 0.1em; background-color: white; } kbd:active { border: 2px gray inset;} img.left { float: left; clear: both; margin-right: 1em; margin-bottom: 0.5em; margin-top: 0.3em; max-width: 45%; } img.right { float: right; clear: both; margin-left: 1em; margin-bottom: 0.5em; margin-top: 0.3em; max-width: 45%; } /* link styles */ a:link, a:visited {color: navy; text-decoration: none; font-weight: bold;} p:hover a, p:hover + p a, ul:hover a, dl:hover a, table:hover a { text-decoration: underline; } a:hover { text-decoration: none !important; border-width: 1px 0px; border-style: none; color: green; background-color: #efefef;} /* navigation menu */ #navmenu { width: 150px; position: fixed; /* f*ck, Opera 8 'loses' abs positioned content within fixed */ position: absolute; top: 0px; right: 0px; padding: 0px; margin: 0px; display: none; /* the TOC script will make it appear */ text-align: left; } #navmenu > li:first-child { font-weight: bold; color: white; background-color: #000033; } #navmenu li { line-height: 1.4em; padding-left: 3px; list-style-type: none; background-color: #2E2E58; color: white; margin: 0px 0px 1px 0px; position: relative; } #navmenu li:hover { background-color: maroon; color: white; } #navmenu > li:first-child:hover { width: auto; right: 0px; } #navmenu > li:hover { width: 298px; position: relative; right: 151px; font-weight: bold; } #navmenu li:hover > ul { display: block; } #navmenu li ul { margin: 0px; padding: 0px; position: absolute; top: 1.4em; right: 141px; width: 150px; margin-top: -9px; /* 1px between list, but with 10px padding */ padding-top: 10px; padding-right: 10px; /* so that the box still overlap; helps with hovering */ font-weight: normal; display:none; } #navmenu li ul li { padding-left: 0px; } /*the links should fill to full size of list item */ #navmenu li a { display: block; text-decoration:none !important; color:white; padding-left: 3px; } #navmenu li a:hover { border-style: none !important; background-color: inherit !important;} #navmenu #toc li.h2 a { padding-left: 0.3em; font-size: 0.9em; font-weight:bold;} #navmenu #toc li.h3 a { padding-left: 0.8em; font-size: 0.8em;} #navmenu #toc li.h4 a { padding-left: 1.2em; font-size: 0.8em; font-style: italic; } /* for IE: with some scripting and these styles the menus also work in IE */ /* Do not put complex selectors IE does not understand in same style declaration!! */ #navmenu li.first { color: white; background-color: #000033; } #navmenu li.expand ul { display: block; } #navmenu li.expand { width: 299px; position: relative; margin-left: -152px; font-weight: bold; background-color: maroon; color: white; } #navmenu li.expand a:hover { background-color: maroon; } #navmenu ul.ulhover { display:block; background-color: #CDD5DD; /* background-color so there's a background so hovering works... */ padding-top: 1px; margin-top: 0px; margin-right: 0em;} /* -------- Requires CSS3 Selectors (O9, IE7, FF, SF) -------- */ /* well implemented by http://www.askthecssguy.com/2006/12/showing_hyperlink_cues_with_cs_1.html */ a[href$='.pdf'], a[rel='pdf'], a[rel*='pdf'], a[rel~='pdf'] { padding-right: 18px; background: transparent url(../images/icons/icon_pdf.png) no-repeat center right; } a[href^="mailto:"] { padding-right: 18px; background: transparent url(../images/icons/icon_mailto.png) no-repeat center right; } a[class ="popup"] { padding-right: 18px; background: transparent url(../images/icons/icon_popup.png) no-repeat center right; } a[href$='.doc'] { padding-right: 18px; background: transparent url(../images/icons/icon_doc.png) no-repeat center right; } a[href$='.xls'] { padding-right: 18px; background: transparent url(../images/icons/icon_xls.png) no-repeat center right; } a[href$='.ppt'] { padding-right: 18px; background: transparent url(../images/icons/icon_ppt.png) no-repeat center right; } a[rel ~='external'] { padding-right: 18px; background: transparent url(../images/icons/icon_external.png) no-repeat center right; } /* faviconize script needs some styling */ img.faviconimg { max-width: 1.1em; margin: 0; padding: 0; margin-left: 2px; border-width: 0px; vertical-align: top; opacity: 0.5; } a:hover img.faviconimg { opacity:1; } p:hover a img, p:hover + p a img, ul:hover a img, dl:hover a img, table:hover a img{ opacity:1; } /* -------- page specific stuff -------- */ /* Sortable tables */ table.sortable span.sortarrow { color: black; padding-left: 0.5em; font-family: sans-serif; } table.sortable th { vertical-align: middle; cursor: pointer; } /* CSS Exp style */ dt span.expdate { font-size: 0.7em; line-height: 2em; color:gray; position:absolute;right:0em;} /* -------- various media styles -------- */ @media print { html, body { border-style:none; margin: 0px; padding: 0px; font-size: 10pt; width: 100%; background-color: transparent;} h1 { border-style: none; } h1:first-letter { margin: 0px; border-style: none; } #navmenu { display:none !important; } h1, h2, h3 { page-break-after: avoid; } img { width: auto; max-width: 100%; } } @media projection { html { font-size: 1.2em; } body { width: auto; padding-left: 3em; } } /* voice styles */ @media speech { title { display:block; speak:normal; } h1, h2, h3 { voice-family: female; } p, dl, ul, ol { voice-family: male; } acronym { speak:spell-out; voice-family: female; } abbr[title]::after { content: "This abbreviation means" attr(title); speak:normal; } acronym[title]::after { content: "This acronym means" attr(title); speak:normal; } } --></style> </head> <body> <h1 class="settitle">ESS -- Emacs Speaks Statistics</h1> <h2 class="majorheading"><a name="TOC0"></a>ESS — Emacs Speaks Statistics</h2> <!-- node-name, next, previous, up --> <div class="node"> <a name="Top"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Introduction">Introduction</a>, Previous: <a rel="previous" accesskey="p" href="#dir">(dir)</a>, Up: <a rel="up" accesskey="u" href="#dir">(dir)</a> </div> <h2 class="unnumbered">ESS: Emacs Speaks Statistics</h2> <p>ESS version 5.14 <pre class="display"> by A.J. Rossini, R.M. Heiberger, K. Hornik, M. Maechler, R.A. Sparapani, S.J. Eglen, S.P. Luque and H. Redestig. </pre> <!-- (Formerly: Doug --> <!-- Bates, Ed Kademan, Frank Ritter and David Smith). --> <blockquote> 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 on Unix, Linux and Microsoft Windows. 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. </blockquote> <ul class="menu"> <li><a accesskey="1" href="#Introduction">Introduction</a>: Overview of features provided by this package <li><a accesskey="2" href="#Installation">Installation</a>: Installing ESS on your system <li><a accesskey="3" href="#Interactive-ESS">Interactive ESS</a>: Interacting with statistical programs <li><a accesskey="4" href="#Entering-commands">Entering commands</a>: Interacting with the ESS process <li><a accesskey="5" href="#Transcript-Mode">Transcript Mode</a>: Manipulating saved transcript files <li><a accesskey="6" href="#ESS-for-the-S-family">ESS for the S family</a> <li><a accesskey="7" href="#Editing">Editing</a>: How to create/edit objects and functions <li><a accesskey="8" href="#Editing-R-documentation">Editing R documentation</a> <li><a accesskey="9" href="#Help">Help</a>: Reading help files <li><a href="#ESS-for-SAS">ESS for SAS</a> <li><a href="#ESS-for-BUGS">ESS for BUGS</a> <li><a href="#ESS-for-JAGS">ESS for JAGS</a> <li><a href="#Miscellaneous">Miscellaneous</a>: Other features of ESS <li><a href="#Mailing-lists_002fbug-reports">Mailing lists/bug reports</a>: How to get assistance with ESS <li><a href="#Customization">Customization</a>: Customizing ESS <li><a href="#Key-Index">Key Index</a> <li><a href="#Concept-Index">Concept Index</a> <li><a href="#Variable-and-command-index">Variable and command index</a> <!-- @detailmenu --> <!-- The Detailed Node Listing - --> <!-- Introduction to ESS --> <!-- * Features:: Why should I use ESS? --> <!-- * New features:: --> <!-- * Credits:: Authors of and contributors to ESS --> <!-- * Latest version:: Getting the latest version of ESS --> <!-- * Manual:: How to read this manual --> <!-- Installing ESS on your system --> <!-- * Unix installation:: Installing ESS on your Unix system --> <!-- * Microsoft Windows installation:: Installing ESS on your MS Windows system --> <!-- * Requirements:: emacs, Operating Systems and Statistical Packages --> <!-- * System dependent:: Other variables you may need to change --> <!-- Starting the ESS process --> <!-- * Multiple ESS processes:: --> <!-- * ESS processes on Remote Computers:: --> <!-- * Customizing startup:: Changing the startup actions --> <!-- Help for the S family --> <!-- * ESS(S)-Editing files:: --> <!-- * iESS(S)-Inferior ESS processes:: --> <!-- * Handling and Reusing Transcripts:: --> <!-- * ESS-help-assistance with viewing help:: --> <!-- * Philosophies for using ESS(S):: --> <!-- * Scenarios for use (possibilities-based on actual usage):: --> <!-- * Customization Examples and Solutions to Problems:: --> <!-- Help for SAS --> <!-- * ESS(SAS)-Design philosophy:: --> <!-- * ESS(SAS)-Editing files:: --> <!-- * iESS(SAS)-Interactive SAS processes:: --> <!-- * ESS(SAS)-Batch SAS processes:: --> <!-- * ESS(SAS)-Function keys for batch processing:: --> <!-- * ESS(SAS)-TAB key:: --> <!-- * ESS(SAS)-Usage scenarios:: --> <!-- * iESS(SAS)-Common problems:: --> <!-- * ESS(SAS)-MS Windows:: --> <!-- Interacting with the ESS process --> <!-- * Command-line editing:: Entering commands and fixing mistakes --> <!-- * Completion:: Completion of object names --> <!-- * Completion details:: Advanced completion concepts --> <!-- * Transcript:: Manipulating the transcript --> <!-- * Command History:: Command History --> <!-- * History expansion:: References to historical commands --> <!-- * Hot keys:: Hot keys for common commands --> <!-- * Statistical Process running in ESS?:: --> <!-- * Other:: Other commands provided by inferior-ESS --> <!-- Manipulating the transcript --> <!-- * Last command:: Manipulating the output from the last command --> <!-- * Process buffer motion:: Viewing older commands --> <!-- * Transcript resubmit:: Re-submitting commands from the transcript --> <!-- * Saving transcripts:: Keeping a record of your S session --> <!-- Editing S functions --> <!-- * Edit buffer:: Edit objects in a specialized buffer --> <!-- * Loading:: Loading source files into the ESS process --> <!-- * Error Checking:: Detecting errors in source files --> <!-- * Evaluating code:: Sending code to the ESS process --> <!-- * Indenting:: Indenting and formatting @Sl{} code --> <!-- * Other edit buffer commands:: Commands for motion, completion and more --> <!-- * Source Files:: Maintaining @Sl{} source files --> <!-- * Source Directories:: Names and locations of dump files --> <!-- Manipulating saved transcript files --> <!-- * Resubmit:: Resubmitting commands from the transcript file --> <!-- * Clean:: Cleaning transcript files --> <!-- Other features of ESS --> <!-- * Highlighting:: Syntactic highlighting of buffers --> <!-- * Graphics:: Using graphics with ESS --> <!-- * Object Completion:: --> <!-- Using graphics with ESS --> <!-- * printer:: The printer() graphics driver --> <!-- * X11:: The X11() (and other X-windows based) driver --> <!-- Bugs and Bug Reporting, Mailing Lists --> <!-- * Bugs:: --> <!-- * Reporting Bugs:: --> <!-- * Mailing Lists:: --> <!-- Customizing ESS --> <!-- * Variables:: Variables for customization --> <!-- * Hooks:: Customizing ESS with hooks --> <!-- * Keybindings:: Changing the default ESS keybindings --> <!-- Variables for customization --> <!-- * Variables for starting ESS:: Variables for starting ESS --> <!-- * Dump file variables:: Variables for dump files --> <!-- * Indentation variables:: Variables controlling indentation --> <!-- * Variables controlling interaction:: Variables controlling interaction --> <!-- with the ESS process --> <!-- @end detailmenu --> </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Introduction"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Installation">Installation</a>, Previous: <a rel="previous" accesskey="p" href="#Top">Top</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">1 Introduction to ESS</h2> <p><a name="index-introduction-1"></a> The S family (S, Splus and R) and SAS statistical analysis packages provide sophisticated statistical and graphical routines for manipulating data. <b>E</b>macs <b>S</b>peaks <b>S</b>tatistics (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. <p>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. <p>A bit of notation before we begin. <em>emacs</em> refers to both <em>GNU Emacs</em> by the Free Software Foundation, as well as <em>XEmacs</em> by the XEmacs Project. The emacs major mode <code>ESS[language]</code>, where <code>language</code> can take values such as <code>S</code>, <code>SAS</code>, or <code>XLS</code>. The inferior process interface (the connection between emacs and the running process) referred to as inferior ESS (<code>iESS</code>), is denoted in the modeline by <code>ESS[dialect]</code>, where <code>dialect</code> can take values such as <code>S3</code>, <code>S4</code>, <code>S+3</code>, <code>S+4</code>, <code>S+5</code>, <code>S+6</code>, <code>S+7</code>, <code>R</code>, <code>XLS</code>, <code>VST</code>, <code>SAS</code>. <p>Currently, the documentation contains many references to <cite>`S'</cite> where actually any supported (statistics) language is meant, i.e., `S' could also mean `XLisp-Stat' or `SAS'. <p><a name="index-interactive-use-of-S-2"></a> <a name="index-using-S-interactively-3"></a>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. <p><a name="index-transcripts-of-S-sessions-4"></a>No special knowledge of Emacs is necessary when using S interactively under ESS. <p><a name="index-programming-in-S-5"></a>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. <ul class="menu"> <li><a accesskey="1" href="#Features">Features</a>: Why should I use ESS? <li><a accesskey="2" href="#New-features">New features</a> <li><a accesskey="3" href="#Credits">Credits</a>: Authors of and contributors to ESS <li><a accesskey="4" href="#Latest-version">Latest version</a>: Getting the latest version of ESS <li><a accesskey="5" href="#Manual">Manual</a>: How to read this manual </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Features"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#New-features">New features</a>, Previous: <a rel="previous" accesskey="p" href="#Introduction">Introduction</a>, Up: <a rel="up" accesskey="u" href="#Introduction">Introduction</a> </div> <h3 class="section">1.1 Why should I use ESS?</h3> <p>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. <p>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: <ul> <li><b>Command-line editing</b> for fixing mistakes in commands before they are entered. The ‘<samp><span class="samp">-e</span></samp>’ flag for S-plus provides something similar to this, but here you have the full range of Emacs commands rather than a limited subset. However, other packages such as XLisp-Stat and S3 do not necessarily have features like this built-in. See <a href="#Command_002dline-editing">Command-line editing</a>. <li><b>Searchable command history</b> for recalling previously-submitted commands. This provides all the features of the ‘<samp><span class="samp">Splus -e</span></samp>’ history mechanism, plus added features such as history searching. See <a href="#Command-History">Command History</a>. <li><b>Command-line completion</b> of both object and file names for quick entry. This is similar to <code>tcsh</code>'s facility for filenames; here it also applies to object names and list components. See <a href="#Completion">Completion</a>. <li><b>Hot-keys</b> for quick entry of commonly-used commands in `S' such as <code>objects()</code> and <code>search()</code>. See <a href="#Hot-keys">Hot keys</a>. <li><b>Transcript recording</b> for a complete record of all the actions in an S session. See <a href="#Transcript">Transcript</a>. <li><b>Interface to the help system</b>, with a specialized mode for viewing S help files. See <a href="#Help">Help</a>. </ul> <p>If you commonly create or modify S functions, you will have found the standard facilities for this (the ‘<samp><span class="samp">fix()</span></samp>’ 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: <ul> <li><b>Object editing</b>. ESS allows you to edit more than one function simultaneously in dedicated Emacs buffers. The ESS process may continue to be used while functions are being edited. See <a href="#Edit-buffer">Edit buffer</a>. <li><b>A specialized editing mode</b> for S code, which provides syntactic indentation and highlighting. See <a href="#Indenting">Indenting</a>. <li><b>Facilities for loading and error-checking source files</b>, including a keystroke to jump straight to the position of an error in a source file. See <a href="#Error-Checking">Error Checking</a>. <li><b>Source code revision maintenance</b>, which allows you to keep historic versions of S source files. See <a href="#Source-Files">Source Files</a>. <li><b>Facilities for evaluating S code</b> such as portions of source files, or line-by-line evaluation of files (useful for debugging). See <a href="#Evaluating-code">Evaluating code</a>. </ul> <p>Finally, ESS provides features for re-submitting commands from saved transcript files, including: <ul> <li><b>Evaluation of previously entered commands</b>, stripping away unnecessary prompts. See <a href="#Transcript-resubmit">Transcript resubmit</a>. </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="New-features"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Credits">Credits</a>, Previous: <a rel="previous" accesskey="p" href="#Features">Features</a>, Up: <a rel="up" accesskey="u" href="#Introduction">Introduction</a> </div> <h3 class="section">1.2 New features in ESS</h3> <ul> Changes/New Features in 5.14: <ul> <li><acronym>ESS[BUGS/JAGS]</acronym>: Batch BUGS is back! For recent OpenBUGS versions, 3.0.8+, a batch BUGS script is once again available, but for Linux only. Therefore, since it seems that BUGS and JAGS must co-exist (rather than a transition from BUGS to JAGS), .bug files are now in <acronym>ESS[BUGS]</acronym> mode and .jag files are in <acronym>ESS[JAGS]</acronym> mode. <acronym>ESS[BUGS]</acronym> now works like <acronym>ESS[JAGS]</acronym> rather than the original mode <acronym>ESS[BUGS]</acronym> mode which was difficult to maintain. Although, <acronym>ESS[BUGS]</acronym> appears to work, there still may be some features missing as well as bugs. <li><acronym>ESS[R]</acronym>: New customizable variable <code>ess-swv-plug-into-AUCTeX-p</code> Commands to Sweave current file and LaTeX the result are now available to AUCTeX users, if this variable is set to <code>t</code>. <li><acronym>ESS[S]</acronym>: <kbd>C-c C-c</kbd> (<code>ess-eval-function-or-paragraph-and-step</code>) is now skipping over comments as the other paragraph functions do. It (and similar functions) should no longer wrongly find ‘<samp><span class="samp">function()</span></samp>’ beginnings inside comments or strings. <li><acronym>ESS[SAS]</acronym>: improved by better support for GNU Emacs </ul> <p>Changes/New Features in 5.13: <ul> <li><acronym>ESS[R]</acronym>: On Windows, for R 2.12.0 and later, the Rterm executables (in subdirectories i386 / x64) now are found as well as for earlier R versions. <li><acronym>ESS[S+]</acronym>: on Windows, both 32- and 64-bit versions of S+ (“S-PLUS”) are found now and made available on the menu. <li><acronym>ESS[R]</acronym>: When prompting for a starting directory, the R version is (always?) correct now. <li><acronym>ESS[R]</acronym>: on non-Windows platforms, the <code>use-dialog-box</code> variable is no longer temporarily changed (to <code>nil</code> for R-x.y.z version functions and to <code>t</code> for <samp><span class="command">R</span></samp> itself), but rather the user customization is obeyed. <li><acronym>ESS[R]</acronym>: more Roxygen improvements. <li>`Rd-preview-help' now generates preview buffers with navigation facilities the same as regular help buffers. <li><acronym>ESS</acronym>: New functions and keys C-c [up] / [down] for evaluating the buffer “from beginning till here”. </ul> <p>Changes/New Features in 5.12: <ul> <li><acronym>ESS[SAS]</acronym> Font-locking: update of PROCs keywords (up to SAS 9.22); error/warnings. <li><acronym>ESS[R]</acronym>: Roxygen improvements: S4 classes; also optionally keep spaces when filling arguments <li><acronym>ESS[Rd]</acronym>: support new keywords: section-name \subsection plus a dozen “new” keywords; should match R 2.12.x now. <li><samp><span class="command">ess-display-help-on-object</span></samp> (<kbd>C-c C-v</kbd>) now <em>caches</em> the list of topics, thus speeding up the improvement feature introduced in 5.9. </ul> <p>Changes/New Features in 5.11: <ul> <li>Filename completion within buffers now adds only trailing characters to complete the filename, rather than expanding to an absolute file path. This filename completion is bound to the TAB key. <li><kbd>M-n P</kbd> in Sweave buffers now prompts for the command to run instead of using <samp><span class="command">pdflatex</span></samp> unconditionally, offering completion from customizable collection <code>ess-swv-pdflatex-commands</code>, the first of which is taken as default and that defaults to <samp><span class="command">texi2pdf</span></samp>. <li><kbd>M-RET</kbd> is now also bound in S language (R and S+) buffers to <samp><span class="command">ess-use-this-dir</span></samp>. It sends <code>setwd(..)</code> to the S process to set the working directory to the one of the source file. </ul> <p>Changes/New Features in 5.10: <ul> <li><kbd>M-RET</kbd> in *S* buffers is now bound to <code>ess-dirs</code>. This function will set Emacs's current directory to be the same as the *S* process. This is useful if you use <code>setwd()</code> within a *S* process. </ul> <p>Changes/New Features in 5.9: <ul> <li>Toolbar: The toolbar now has an icon for starting Splus. <li>Indentation: New documentation and code has been added to make it easier to change how ESS indents code. In particular, see <code>ess-default-style</code>, <code>ess-own-style-list</code> and the documention subsection “Changing indentation styles”. <li><samp><span class="command">ess-display-help-on-object</span></samp> (<kbd>C-c C-v</kbd>) now offers completion candidates for help file aliases, in addition to object names. <li>Font locking: is now turned on even without <samp><span class="command">window-system</span></samp> is <code>nil</code>, whenever <var>ess-font-lock-mode</var> is non-nil, i.e., by default. <li><acronym>ESS</acronym> script editing: ess-eval-deactivate-mark default is now t, as suggested by Leo Alekseyev and subsequent “unanimous” ESS-help discussion. <li><acronym>ESS[R]</acronym>: Editing support for “#!” (Rscript / littler) editing, thanks to Jeffrey Arnold. <li><acronym>ESS[R]</acronym>: Now finds all R versions, both 64-bit and 32-bit, on some 64-bit Windows machines. Please report back to ess-core success or failure on your 64-bit Windows machine. <li>ESS Manual now more visually pleasing; <a href="http://ess.r-project.org/Manual/ess.html">http://ess.r-project.org/Manual/ess.html</a> <li><acronym>ESS[R]</acronym>: Roxygen on XEmacs no longer font locks for now (as it required missing features and hence broke ESS startup, there). <li><acronym>ESS[R]</acronym>: Roxygen has a sub-menu on the [ESS] menu. <li><acronym>ESS[R]</acronym>: Function <samp><span class="command">ess-rutils-htmldocs</span></samp> in <samp><span class="file">ess-rutils.el</span></samp> offers an alternative to <code>help.start()</code> for navigating R documentation, using the <samp><span class="command">browse-url</span></samp> Emacs function. </ul> <p>Changes/New Features in 5.8: <ul> <li><acronym>ESS[R]</acronym>: New <samp><span class="file">ess-rutils.el</span></samp> with utilities for listing, loading, installing, and updating packages, as well as object manipulation (listing, viewing, and deleting). It also provides an alternative to <code>RSiteSearch()</code> that uses the <samp><span class="command">browse-url</span></samp> function, so results can be viewed in an Emacs web browser. <li><acronym>ESS[R]</acronym>: much more extensive Roxygen interface, via ess-roxy.el from Henning Redestig. Ess-roxy supports filling of roxygen fields, generation and updating roxygen templates, completion of roxygen tags, basic navigation (marking and moving between entries), folding using hs-minor-mode and preview of the Rd file. <li>Emacs lisp files have got better names (partly, for now). </ul> <p>Changes/New Features in 5.7: <ul> <li><acronym>ESS[R]</acronym>: loading a source file (<kbd>C-c C-l</kbd>) now works in Windows, similarly to other platforms; (further; it had accidentally been broken in ESS 5.6 on all platforms) </ul> <p>Changes/New Features in 5.6: <ul> <li><acronym>ESS[R]</acronym>: help() calls have to differ from old default, with newer versions of R; currently via .help.ESS <- function(...) hack. </ul> <p>Changes/New Features in 5.4: <ul> <li><acronym>ESS[SAS]</acronym>: The long overdue change from <code>make-regexp</code> to <code>regexp-opt</code> for font-locking is complete. The new <code>regexp-opt</code> 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 <code>ess-sas-run-regexp-opt</code> to <code>nil</code> will result in the old code being used. <li><acronym>ESS[BUGS]</acronym> and <acronym>ESS[JAGS]</acronym>: typing <code>=</code> now results in <code><-</code>. <li><acronym>ESS[R]</acronym> function arguments “show” <code>(ess-r-args-show)</code> now uses the new <code>(tooltip-show-at-point)</code> contributed by Erik Iverson. <li>Toolbar icons now also work in (beta) Emacs 23. <li><acronym>ESS[S]</acronym>: New function <code>ess-change-directory</code> for setting both emacs' current directory and the directory of an *R* or *S* buffer. <li><acronym>ESS[S]</acronym> when transient-mark-mode is true, the mark is now kept, rather than deactivated, thanks to a patch from David Reitter. </ul> <p>Changes/New Features in 5.3.11: <ul> <li><acronym>ESS[SAS]</acronym>: work around bug in Emacs 22.2 & 22.3 which fails to set case-fold fontification automatically. <li>Rd mode: support new keyword 'Rdversion' <li><acronym>ESS[R]</acronym>: now again works with Emacs 21.x </ul> <p>Changes/New Features in 5.3.10: <ul> <li>Fixed noweb-mode bug accidentally introduced into 5.3.9 <li>In noweb-mode, e.g., Rnw-mode, electric “<” also inserts closing “@". Further, the code chunk boundaries are better kept up-to-date, such that code[R] <-> text[LaTeX] minor mode switching should happen more reliably. <li>In noweb-mode, fix a buglet in rare [Enter] or [Tab] behavior; further, by default disable the former `[[' .. `]]' code-protection-when-filling behavior which has been found to be buggy. </ul> <p>Changes/New Features in 5.3.9: <ul> <li><acronym>ESS[SAS]</acronym>: evince PDF viewer now supported as well; search order: evince, Xpdf, Adobe/Acrobat Reader <li><acronym>ESS[R]</acronym>: added support for Roxygen, potentially to be extended. <li><acronym>ESS[S]</acronym> (and R): inferior (<code>*R*</code>) and transcript modes no longer fontify language keywords (such as <code>for</code>, <code>in</code>, etc). <li>i<acronym>ESS[Stata]</acronym><!-- /@w -->: Customize the <code>ess-sta-delimiter-friendly</code> setting to <code>t</code> to convert embedded semi-colons to newlines for Stata processing. <li>Sweave fix for embedded blanks in PDF reader and PDF files <li>Several fixes for Major Mode Convention violations in <code>ess-mode</code> and <code>noweb-mode</code>. <li><acronym>ESS[JAGS]</acronym>: <code>M-x comment-region</code> now available! <li><acronym>ESS[S]</acronym> The <code>ess-swv-*</code> commands (and keybindings) are now in a submenu of the “Noweb” menu, when editing Sweave files. </ul> <p>Changes/New Features in 5.3.8: <ul> <li><acronym>ESS[JAGS]</acronym>: more separation from <acronym>ESS[BUGS]</acronym> (as much as is currently planned); now <kbd>C-c C-c</kbd> on an empty <samp><span class="file">.jmd</span></samp> creates a template as it should; symbolic links are created for CODA output so BOA is happy: from <samp><span class="file">index.txt</span></samp> to <samp><span class="file">.ind</span></samp> and <samp><span class="file">chain#.txt</span></samp> to <samp><span class="file">#.out</span></samp> <li><acronym>ESS[SAS]</acronym>: buffer-local <code>ess-sas-submit-command</code> and <code>ess-sas-submit-command-options</code> now recognized by <code>ess-sas-submit-region</code> <li><acronym>ESS[S]</acronym>: When trying to evaluate code in an S language buffer and there is no associated process, now start R automatically instead of signalling an error. Also, restart R if there is an associated process which is not running. However, do not start R just via the “electric” <kbd>(</kbd> (<code>ess-r-args-auto-show</code>). <li><acronym>ESS[S]</acronym>: For (one-line) functions withOUT '{ .. }' bodys, the end of function is now correctly found more often. This notably improves <kbd>C-c C-c</kbd> (<code>ess-eval-function-or-paragraph-and-step</code>). <li><acronym>ESS[JAGS]</acronym>: cleanup/re-organization of elisp code; symbolic links for CODA output are now only created by the new JAGS <code>system</code> command in version 1.0.3; specify whether this command is available via <code>ess-jags-system</code>; if not present, then no links are created so that the <code>*shell*</code> buffer does not become unresponsive during the batch run </ul> <p>Changes/New Features in 5.3.7: <ul> <li><acronym>ESS</acronym>: <code>ess-default-style</code> now *is* customizable, i.e., changing its value in <samp><span class="file">~/.emacs</span></samp> now does have the desired effect. <li><acronym>ESS</acronym>: <code>ess-font-lock-mode</code> is a new variable (default: t) which controls whether font-locking is enabled in ESS buffers. <li><acronym>ESS[R]</acronym>: for XEmacs on Windows; another tweak to find R versions <li><acronym>ESS[SAS]</acronym>: font-locking updated for ODS and SAS Bayesian Procedures; a more consistent handling of SAS options by <code>ess-sas-submit-command-options</code> which is buffer-local; portable snooze for MS Windows via customize-able <code>ess-sleep-for</code> (floats welcome); Xpdf now supported as a PDF viewer <li><acronym>ESS[Rnw]</acronym>: now also works with “emacs -nw” and Emacs 22. <li><acronym>ESS[JAGS]</acronym>: now requires JAGS 1.0 (see the new ESS for JAGS help section for more information): both need work; suggestions welcome <li><acronym>ESS[R]</acronym>: [TAB] completion now uses the R-internal completion mechanism (for R >= 2.5.0). <li><acronym title="[S]">ESS[R]</acronym> ([S]): interpretation of “_” as assignment has been removed in <code>ess-continued-statement-p</code> for R and S. <li>several internal code cleanups. <li><acronym title="[S]">ESS[R]</acronym>: An experimental version of a new command <code>Rgui</code> on MS Windows to send lines directly from emacs to <code>Rgui</code> is available in file <code>lisp/essd-rgui.el</code>. Preliminary documentation is in file <code>doc/rgui-doc.txt</code>. </ul> <p>Changes/New Features in 5.3.6: <ul> <li><acronym>ESS</acronym>: for XEmacs, using “gnuclient” (without a “-q”) works for things like fix() after M-x gnuserv-start has been done. <li><acronym title="[S]">ESS[R]</acronym>: M-x R-newest should now work in more situations on MS Windows, e.g., when R has been installed in a non-default "ProgramFiles" directory tree. In these cases, there's no need to specify the name (and full path) of the R program anymore. <li><acronym title="[S]">ESS[R]</acronym>: For XEmacs, startup (with new tooltip code) works again. </ul> <p>Changes/New Features in 5.3.5: <ul> <li><acronym title="[S]">ESS[R]</acronym> a new defun is available, <kbd>M-x R-newest</kbd>, which will start the newest version of R that it can find on your system. <li><acronym title="[S]">ESS[R]</acronym> add Sven Hartenstein's “R function arguments tips” functionality, via new file <samp><span class="file">../lisp/essd-r-args.el</span></samp>. Note that this includes an “electric "("” behavior inside <code>R-mode</code> which is <em>active by default</em> and can be customized via <code>ess-r-args-electric-paren</code>; i.e., use <code>(setq ess-r-args-electric-paren nil)</code> to turn it off. Further, <code>ess-r-args-show-as</code> allows to switch to the “tooltip” mode. <li><acronym>ESS</acronym>: functions <code>ess-get-pdf-viewer</code> and *-ps-viewer; built on new customizable variables <code>ess-pdf-viewer-pref</code> and <code>ess-ps-viewer-pref</code>; currently used in <code>ess-swv-PDF</code> and <code>*-PS</code>. <li><acronym title="[S]">ESS[R]</acronym> Improved <code>ess-swv-PDF</code> to run pdf viewer only if pdflatex was ok <li><acronym title="[S]">ESS[R]</acronym> Improved <code>ess-swv-weave</code> to start R automatically if none is running. <li><acronym>ESS</acronym>: Do no longer ask <em>which</em> ESS process to use if there is only one. </ul> <p>Changes/New Features in 5.3.4: <ul> <li><acronym title="[S]">ESS[R]</acronym> now better work with options(error=recover); and the new default of CHM help files on windows. <li><acronym title="[S]">ESS[R]</acronym> some more cleanup in the “sweave” functions <li>miscellaneous fixes </ul> <p>Changes/New Features in 5.3.3: <ul> <li><acronym>ESS[S]</acronym> fix buglet (5.3.2 only) which left command prompt in “execute buffer” and hence help files. <li>new customizable variable <code>ess-display-buffer-reuse-frames</code> set to true (which changes default behavior) such that execution or help *frames* are reused. </ul> <p>Changes/New Features in 5.3.2: <ul> <li>Classic BUGS now supported by <code>(require 'essd-bugs)</code> with <acronym>ESS[BUGS]</acronym> and JAGS by <code>(require 'essd-jags)</code> with <acronym>ESS[JAGS]</acronym>. But, only one of them can be used at a time since they don't play nice together. Also, <kbd>C-c C-c</kbd> is now bound to the function <code>ess-bugs-next-action</code> (<kbd>F12</kbd> has been retired). And finally, note that <samp><span class="file">essl-bug.el</span></samp> is deprecated and the replacement is <samp><span class="file">essl-bugs.el</span></samp>. <li><acronym title="[S]">ESS[R]</acronym> Improved some of the “Sweave-make” functions (yet scarcely documented) in <samp><span class="file">ess-swv.el</span></samp>. <li><acronym>ESS[S]</acronym> No longer mess with .Last.value (nor in other “languages”). </ul> <p>Changes/New Features in 5.3.1: <ul> <li>See the docs for 2 ways to install <acronym>ESS</acronym> for XEmacs <ol type=1 start=1> <li>by uncommenting the XEmacs part of Section 1 of <samp><span class="file">Makeconf</span></samp> and performing <code>make install</code> <li>by unpacking either <samp><span class="file">ess-5.3.1.tgz</span></samp> or <samp><span class="file">ess-5.3.1.zip</span></samp> into <samp><span class="file">PREFIX/lib/xemacs/site-packages</span></samp> on unix or <samp><span class="file">PREFIX\XEmacs\site-packages</span></samp> on windows </ol> <li><acronym title="[S]">ESS[R]</acronym>: fixed bugs so that Rterm.exe can be found by XEmacs <li><acronym>ESS[S]</acronym>: <kbd>ess-toggle-S-assign-key</kbd> is slightly changed; in particular, the default <code>ess-assign-key</code> is now <kbd>C-x =</kbd>. <li><acronym title="[S]">ESS[R]</acronym>: <kbd>M-x R-site-search</kbd> is a new (slightly experimental) utility similar to R's <code>RSiteSearch(..)</code> but with the advantage of using Emacs' preferred browser, see <code>browse-url-browser-function</code> </ul> <p>Changes/New Features in 5.3.0: <ul> <li><acronym>ESS[BUGS]</acronym>: sanely re-format statistical output, <samp><span class="file">.bog</span></samp>, from scientific notation to numbers rounded with 4 decimal places with <kbd>M-x ess-bugs-sci-round-to-4-dp</kbd>. <li>The keys for navigating among section headings in help buffers worked, but only for one language per session; they should now work for multiple languages. (They were also broken on Windows machines.) <li><acronym>ESS[S]</acronym> long standing buglets in the internal logic for loading lisp code on Windows. Particularly fixed behavior in help mode with S-plus GUI. <li>New variable, <code>ess-use-inferior-program-name-in-buffer-name</code>, which enables using the executable name instead of the dialect name for R. Feature request. <li><acronym>ESS[S]</acronym> <kbd>ess-execute-screen-options</kbd> now also works correctly when there is more than one window *side-by-side* in the same frame and runs in the correct buffer also when there is more than one S buffer. <li>i<acronym>ESS[S]</acronym><!-- /@w --> new functions <code>ess-eval-paragraph-and-step</code> and <code>ess-eval-function-or-paragraph-and-step</code> are bound to keys <kbd>C-c C-p</kbd> and <kbd>C-c C-c</kbd> respectively and to the menu in <acronym>ESS</acronym>-mode; also bound in the help mode (for evaluating examples). <li><acronym>ESS[S]</acronym> new function <code>ess-toggle-S-assign-key</code> allows to assign the “ <- ” insertion to an arbitrary key. </ul> </ul> <ul> Changes/New Features in 5.2.12: <ul> <li><acronym>ESS[SAS]</acronym>: <kbd>M-;</kbd> fixed, but the XEmacs function <code>comment-dwim</code> may be broken, if so, use <kbd>M-x comment-region</kbd> and <kbd>M-x uncomment-region</kbd> 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 <kbd>F</kbd>-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. <li>Rterm/Cygwin combination works under Microsoft Windows. <li><acronym title="[S]">ESS[R]</acronym>: internal calls use baseenv() instead of NULL and define 'baseenv' where needed. <li>New experimental support for installing ESS. See the file <samp><span class="file">lisp/ess-install.el</span></samp>. </ul> <p>Changes/New Features in 5.2.11: <ul> <li>ESS Info entry and <samp><span class="file">dir</span></samp> handled more effectively for GNU Emacs users <li><acronym>ESS[SAS]</acronym>: temporary files created for batch submission of a region are now named based on the current file; see <code>ess-sas-file-root</code> for details; all <code>lag</code> and <code>dif</code> functions now fontified correctly <li>iESS[SAS]: fixed a few nagging bugs, however, still does not appear to work at this time; please let us know if you have any ideas. <li><acronym>ESS[S]</acronym>: Support for running other versions of Splus has been added for unix. Two new variables, <code>ess-s-versions</code> and <code>ess-s-versions-list</code>, are used to tell ESS what other versions of Splus you would like to run. </ul> <p>Changes/New Features in 5.2.10: <ul> <li><acronym title="[S]">ESS[R]</acronym>: ess-r-versions can no longer be customized (since the customization was not taking effect unless customizations were loaded before ESS). Its value has been changed so that it will also find R executables beginning “R-devel” and “R-patched”. If you wish to change this variable, it must be set in your <samp><span class="file">.emacs</span></samp> before ESS is loaded. <li>Installation with GNU Make enhanced: unix and unix-like operating systems will now be able to install <acronym>ESS</acronym> for all users in either a GNU Emacs site-lisp or an XEmacs package configuration by editing <samp><span class="file">lisp/ess-site.el</span></samp> and <samp><span class="file">Makeconf</span></samp> accordingly, then issuing <code>make install</code> <li><acronym>ESS[S]</acronym>: Filename completion (inside strings) now also works in XEmacs for R and S-plus. <!-- working around a bug in XEmacs --> </ul> <p>Changes/New Features in 5.2.9: <ul> <li><acronym title="[S]">ESS[R]</acronym> for Windows: the \ directory character bug with respect to ess-load-file has been eradicated. <li>i<acronym>ESS[SAS]</acronym><!-- /@w -->: <kbd>C-c C-r</kbd> and <kbd>C-c C-b</kbd> once again work as intended and documented. <li><acronym>ESS[S]</acronym>: M-x ess-fix-EQ-assign is a bit more agressive. <li><acronym>ESS[S]</acronym>: Imenu now also shows setAs(), etc. <li><acronym title="[S]">ESS[R]</acronym>: R function pattern enhanced with underlying code such that <kbd>M-C-a</kbd> (<code>ess-beginning-of-function</code>) etc now work for many more cases, including S4 method definitions. <li>i<acronym title="[S]">ESS[R]</acronym><!-- /@w -->: myOwnhelp(1) no longer wrongly triggers help(1). <li><acronym title="[S]">ESS[R]</acronym>: Improved detection of bogus help buffers: valid help buffers containing with the string “no documentation”(e.g. contour) were being treated as bogus. <li><acronym title="[S]">ESS[R]</acronym>: In R help buffers, if <code>options("help.try.all.packages" = TRUE)</code> then <code>?rlm</code> will list which packages rlm is defined in. This help buffer is not bogus, but instead is now relabelled “*help[R](rlm in packages)*”. <li><acronym>ESS[STA]</acronym>: add “//” as comment starting character to syntax-table. </ul> <p>Changes/New Features in 5.2.8: <ul> <li>iESS: [Tab] completes <strong>file</strong> names “inside string” as in earlier (<= 5.2.3) ESS versions. </ul> <p>Changes/New Features in 5.2.7: <ul> <li>If you use Custom to change the variable ess-toolbar-items, the new toolbar is used in all subsequent ESS buffers. <li><acronym>ESS[SAS]</acronym>: new feature: if ess-sas-log-max >0 and your .log grows to more than ess-sas-log-max bytes, just the first ess-sas-log-max bytes are refreshed; this is helpful when your .sas program generates lots of error messages and gets too big for emacs to display <li><acronym>ESS[R/S]</acronym>: <kbd>M-;</kbd> in R/S editing modes will now indent with either one or two hashes depending on context. <li><acronym title="[S]">ESS[R]</acronym>: David Whiting's Sweave extensions (to 'noweb') are now available (from ess-swv.el loaded by default). </ul> <p>Changes/New Features in 5.2.6: <ul> <li>Removed non-ASCII characters in a few files. <li><acronym title="[S]">ESS[R]</acronym>: now works better when UTF-8 locale is active; in particular, you get correct directional quotes in R's startup message for R-devel (unstable development version of R 2.1.0) when using environment variables LANGUAGE=en@quot LC_ALL=en_US.UTF-8 <li><acronym>ESS[SAS]</acronym>: toggling of .log mode improved (<kbd>F10</kbd>); toggling of .lst mode now also available (<kbd>C-F10</kbd>); killing all buffers associated with .sas program no longer bound to <kbd>C-F10</kbd> since its a bit overzealous. <li>S-Plus 7 for Windows is now recognized. <li><acronym>ESS[S]</acronym> (incl. R): in auto-fill mode, strings are not wrapped anymore. <li><acronym>ESS[S]</acronym> (incl. R): font-lock now correctly differs between R and S, e.g., for "_"; both now fontify warning(.) and S does terminate() additionally. <li>Support for `bell' aka `beep' aka `ding' aka `alarm' in all inferior modes: When \a is output “to the the console” at the beginning of a line, the bell is rung. </ul> <p>Changes/New Features in 5.2.5: <ul> <li><acronym title="[S]">ESS[R]</acronym>: <kbd>C-c C-q</kbd> or ‘<samp><span class="samp">Quit S</span></samp>’ from the menu now should work (again and less klunkily) and do not append ‘<samp><span class="samp">-exited</span></samp>’ to the buffer name. Further, the behavior of <code>(ess-cleanup)</code>, called from ess-quit, now depends on the new customizable variable <code>ess-S-quit-kill-buffers-p</code> which defaults to <code>nil</code>. Consequently, the question <em>“Delete all buffers associated with ..?”</em> will not be asked anymore by default. <li><acronym>ESS[SAS]</acronym> – ess-ebcdic-to-ascii-search-and-replace will now work with the <code>recode</code> application as well which is available on many platforms <li><acronym>ESS[S]</acronym> (incl. R): Name completion for slots of S4 objects now works! </ul> <p>Changes/New Features in 5.2.4: <ul> <li>The documentation now includes an overview of how to use the emacs TAGS facility for S functions. (The distribution also used to contain a directory <samp><span class="file">etc/other/Tags</span></samp> where a ~1990 version of <samp><span class="file">etags.c</span></samp> was distributed; this is no longer relevant and so has been deleted.) <li><acronym>ESS[SAS]</acronym> – When you are working with EBCDIC files on an ASCII platform, .log NOTEs may display as gibberish since the EBCDIC characters are not converted to ASCII prior to their display. So, the function ess-ebcdic-to-ascii-search-and-replace is provided for convenience and is bound to <kbd>C-F11</kbd>. This function requires the <code>dd</code> command (only available on unix or unix-like platforms). <li>ESS: Completion of object names is now always done dynamically rather than allowing the option of using a pre-computed database (by <code>ess-create-object-name-db</code>) since modern computers seem fast enough for dynamic completion. (We expect few users, if any, have been using the pre-computed database method.) <li>ESS: object completion in iESS buffers running on Windows was very slow (for GNU Emacs, but not XEmacs) and has now been fixed. Further, it was more or less broken for all versions of S-plus 6.x, and has been fixed to work everywhere but with the Windows' GUI of S-plus. The list of objects now shows unique names also when an object appears more than once in the search path. <li><acronym title="[S]">ESS[R]</acronym>: Completion of object names now also includes those starting with “.”. </ul> <p>Changes/New Features in 5.2.3: <ul> <li>ESS: When new inferior ESS processes are created, by default they will replace the current buffer (this restores behavior from pre 5.2.0). If you wish new ESS processes to start in another window of the current frame, set inferior-ess-same-window to nil. <li>New variables inferior-Splus-args and inferior-R-args provide a way to pass command line arguments to starting S and R processes. </ul> <p>Changes/New Features in 5.2.2: <ul> <li>bug-fixes for 5.2.1 (require 'executable), html docs, etc. <li>ess-lisp-directory/../doc/info added to Info-directory-list if ess-info not found by info <li><acronym title="[S]">ESS[R]</acronym>: If you have other versions of R on your exec-path, such as "R-1.8.1" with Unix or "rw1081" with Windows, ESS will find them and create appropriate functions, such as <kbd>M-x R-1.8.1</kbd> or <kbd>M-x rw1081</kbd>, for calling them. By default only Unix programs beginning "R-1" and "R-2" and Windows programs parallel to the version of R in your exec-path will be found, but see ess-r-versions and ess-rterm-versions for ways to find other versions of R. <li><acronym title="[S]">ESS[R]</acronym>: Other versions of R, such as "R-1.8.1" on Unix and "rw1081" on Windows, are added to the "ESS / Start Process / Other" menu. <li><acronym>ESS[S]</acronym>: If you have other versions of S-Plus on your Windows computer, such as S-Plus 6.1 or S-Plus 4.5, ESS will find them and create appropriate functions, such as <kbd>M-x splus61</kbd>, for calling the console version (Sqpe) inside an emacs buffer. By default only programs installed in the default location will be found, but see ess-SHOME-versions for ways to find other versions of S-Plus. <li><acronym>ESS[S]</acronym>: Other versions of Sqpe on Windows, such as "splus61", are added to the "ESS / Start Process / Other" menu. <li><acronym title="[S]">ESS[R]</acronym>: (bug fix) ess-quit (bound to <kbd>C-c C-q</kbd>) should now quit the inferior R process, when issued from either the inferior buffer, or from a .R buffer. </ul> <p>Changes/New Features in 5.2.1: <ul> <li><acronym>ESS[S]</acronym> (R and S-plus): now have toolbar support with icons to evaluate code in the inferior process or to switch there. This code is experimental and likely to change as XEmacs/Emacs issues get resolved. The toolbar should be enabled if your Emacs displays images, but can be disabled with the variable ess-use-toolbar. Thanks to David Smith from Insightful for the S-plus logo. <li><acronym>ESS[SAS]</acronym>: ess-sas-graph-view (<kbd>F12</kbd>) enhanced; you can specify external file viewers for each graphics file type via the alist ess-sas-graph-view-viewer-alist; also .jpg/.gif are now handled by image-mode on XEmacs, if available, otherwise by graphics primitives as before </ul> <p>Changes/New Features in 5.2.0: <ul> <li><acronym>ESS[BUGS]</acronym>: new info documentation! now supports interactive processing thanks to <a href="mailto:Aki.Vehtari@hut.fi">Aki Vehtari</a>; new architecture-independent unix support as well as support for BUGS v. 0.5 <li><acronym>ESS[SAS]</acronym>: convert .log to .sas with ess-sas-transcript; info documentation improved; Local Variable bug fixes; SAS/IML statements/functions now highlighted; files edited remotely by ange-ftp/EFS/tramp are recognized and pressing SUBMIT opens a buffer on the remote host via the local variable ess-sas-shell-buffer-remote-init which defaults to "ssh"; changed the definition of the variable ess-sas-edit-keys-toggle to boolean rather than 0/1; added the function ess-electric-run-semicolon which automatically reverse indents lines containing only "run;"; <kbd>C-F1</kbd> creates MS RTF portrait from the current buffer; <kbd>C-F2</kbd> creates MS RTF landscape from the current buffer; <kbd>C-F9</kbd> opens a SAS DATASET with PROC INSIGHT rather than PROC FSVIEW; "inferior" aliases for SAS batch: <kbd>C-c C-r</kbd> for submit region, <kbd>C-c C-b</kbd> for submit buffer, <kbd>C-c C-x</kbd> for goto .log; <kbd>C-c C-y</kbd> for goto .lst <li><acronym>ESS[S]</acronym>: Pressing underscore ("_") once inserts " <- " (as before); pressing underscore twice inserts a literal underscore. To stop this smart behaviour, add "(ess-toggle-underscore nil)" to your .emacs after ess-site has been loaded; ess-dump-filename-template-proto (new name!) now can be customized successfully (for S language dialects); Support for Imenu has been improved; set ess-imenu-use-S to non-nil to get an "Imenu-S" item on your menubar; ess-help: Now using nice underlines (instead of `nuke-* ^H_') <li><acronym title="[S]">ESS[R]</acronym>: After (require 'essa-r), <kbd>M-x ess-r-var</kbd> allows to load numbers from any Emacs buffer into an existing *R* process; <kbd>M-x ess-rdired</kbd> gives a “directory editor” of R objects; fixed ess-retr-lastvalue-command, i.e. .Last.value bug (thanks to David Brahm) <li>ESS: Support for creating new window frames has been added to ESS. Inferior ESS processes can be created in dedicated frames by setting inferior-ess-own-frame to t. ESS help buffers can also open in new frames; see the documentation for ess-help-own-frame for details. (Thanks to Kevin Rodgers for contributing code.) </ul> <p>Changes/New Features in 5.1.24: <ul> <li>The version number is now correct even inside ESS/Emacs </ul> <p>Changes/New Features in 5.1.23: <ul> <li>Minor more Makefile clean up. </ul> <p>Changes/New Features in 5.1.22: <ul> <li>Besides info documentation, PDF and HTML documentation are also provided (instead of built using "make") and available on the web as well; see <a href="http://ess.r-project.org/">ESS web page</a> and <a href="http://lib.stat.cmu.edu/general/ESS/doc">StatLib</a> <li>Now that info documentation is available, the README.* files are no longer supported. However, they are still distributed for what it's worth. <li>ESS is now an XEmacs package! See <a href="http://www.xemacs.org/Install/index.html">XEmacs Installation HOWTO</a> for details (specifically, items 10-15). <li><acronym>ESS[SAS]</acronym>: more user-friendly enhancements for remote SAS batch jobs with Kermit file transfers (LOG and OUTPUT function key features now supported). Multiple shells now supported so you can run SAS on different computers from different buffers by setting the buffer-local variable ess-sas-shell-buffer to unique buffer names. <li>Major re-vamping of Makefile/Makeconf. </ul> <p>Changes/New Features in 5.1.21: <ul> <li><acronym>ESS[SAS]</acronym>: info documentation now available!, see ESS->Help for SAS; <kbd>F12</kbd> opens GSASFILE nearest point for viewing either within emacs, when available, or via an external viewer; more syntax highlighting keywords; more enhancements for remote SAS batch jobs with Kermit; new framework for remote SAS interactive jobs, see ess-remote <li><acronym>ESS[S]</acronym>: info documentation now available!, see ESS->Help for the S family <li>Makefile: tag now independent of rel; info files made by doc/Makefile and installed in new info sub-directory </ul> <p>Changes/New Features in 5.1.20: <ul> <li>New `options()$STERM' in the S dialects (S, S-Plus, R). The S program can determine the environment in which it is currently running. ESS sets the option to `iESS' or `ddeESS' when it starts an S language process. We recommend other specific values for S language processes that ESS does not start. <li>New `ess-mouse-me' function, assigned to S-mouse-3 by default. User may click on a word or region and then choose from the menu to display the item, or a summary, or a plot, etc. This feature is still under development. <li>GNU Emacs 21.1 is now supported (fixed for S dialects, SAS & BUGS), (some from Stephen Eglen). <li>XEmacs 21.x is now supported (fixed w32-using-nt bug) <li>XEmacs on Win (NT) is better supported. <li>Workaround for bug in Sqpe+6 (S-PLUS 6 for Win). <li>should now work even when imenu is not available (for old XEmacsen). <li><acronym>ESS[SAS]</acronym>: XEmacs-Imenu fix; <kbd>C-TAB</kbd> is globalized along with your function-key definitions, if specified; you can specify your SAS library definitions outside of autoexec.sas for ess-sas-data-view with SAS code placed in the variable ess-sas-data-view-libname, also the dataset name is defaulted to the nearest permanent dataset to point; Speedbar support now works for permanent datasets, please ignore first./last.; new font-locking is now the default with more improvements for font-locking PROCs, macro statements, * ; and %* ; comments; you can toggle sas-log-mode with <kbd>F10</kbd> which will font-lock your .log (if it isn't too big); submit remote .sas files accessed with ange-ftp, EFS or Tramp (Kermit is experimental) by setting ess-sas-submit-method to 'sh; ess-sas-submit-command and ess-sas-submit-command-options are buffer-local so you can have local file variable sections at the end of your .sas files to request different executables or specify special options and the local file variables are re-read at submit instead of only at file open so that if you make a change it is picked up immediately; <li><acronym>ESS[BUGS]</acronym>: font-lock with `in' fixed. <li>for STATA: font-lock bug fixed. <li>for Rd mode: <kbd>C-c C-v</kbd> and `switch-process' in menu. further, <kbd>C-c C-f</kbd> prefix (Rd-font) for inserting or surrounding a word by things such as \code{.}, \code{\link{.}}, \emph{.} etc. <li>new functions (ess-directory-function) and (ess-narrow-to-defun) ess-directory <-> default-directory logic (Jeff Mincy). <li>Re-organized Makefile and fixed a few bugs. </ul> <p>Changes/New Features in 5.1.19: <ul> <li>S+6 now supported (Tony Rossini (Unix) and Rich Heiberger (Windows)) <li>New BUGS support through <acronym>ESS[BUGS]</acronym> mode (Rodney Sparapani) Templates assist you in writing .bug and .cmd code (.cmd and .log are replaced by .bmd and .bog to avoid emacs extension collisions). Substitution" parameters facilitate "automagic" generation of data...in" and "init...in" filenames, "const N=" from your data file and "monitor()/stats()" commands. Activated by pressing <kbd>F12</kbd>. <li>Fixes for `ess-smart-underscore' SAS breakage (Rich Heiberger) <li>You can change between PC and Unix, local and global SAS function-key definitions interactively (Rich Heiberger) <li><kbd>C-Submit</kbd> a highlighted region to SAS batch (Rodney Sparapani) <li>New and improved SAS syntax highlighting (Rodney Sparapani) To get the new functionality, set ess-sas-run-make-regexp to nil. Also available in .log files via <kbd>F10</kbd>. <li>Open a permanent SAS dataset for viewing via <kbd>F9</kbd> (Rodney Sparapani) You must have the library defined in autoexec.sas for it to work. <li>User-friendly defaults for `sas-program', `ess-sas-batch-pre-command' and `ess-sas-batch-post-command' as well Customize support for these and other <acronym>ESS[SAS]</acronym> variables (Rodney Sparapani) <li>`ess-sas-suffix-2' now defaults to .dat via <kbd>F11</kbd> (Rodney Sparapani) <li>Emacs/XEmacs, Unix/Windows issues collectively handled in ess-emcs.el <li>defadvice solves problem of missing *ESS* (thanks to Jeff Mincy) <li>Improved manual a bit by including things that were only in `README'. </ul> <p>Changes/New Features in 5.1.18: <ul> <li>New `ess-smart-underscore' function, now assigned to "_" by default. Inserts `ess-S-assign' (customizable " <- "), unless inside string and comments where plain "_" is used instead. (MM) <li>Fixes for longstanding interactive SAS breakage (RMH) </ul> <p>Changes/New Features in 5.1.17: <ul> <li>Documentation for Windows Installation (Rich Heiberger) <li>removal of ess-vars, finalization of customize support (in the sense that there is no more use of ess-vars, but that we need to fix ess-cust) (AJ Rossini) <li>Many small (and large) fixes/contributions (MMaechler) <li>addition of the "S-equal" variable and provide <kbd>M-x ess-add-MM-keys</kbd> a way to remap "_" to `ess-S-assign', typically " <- ", but customizable. (MMaechler) </ul> <p>Changes/New Features in 5.1.16: <ul> <li>BUG FIXES <li>Better SAS support </ul> <p>Changes/New Features in 5.1.15: <ul> <li>BUG FIXES </ul> <p>Changes/New Features in 5.1.14: <ul> <li>Yet more fixes to SAS mode, (Rich Heiberger and Rodney Sparapani) <li>Customize support (for most Emacsen which support it) (AJRossini) <li>ARC and ViSta support out of the box, and fixes for XLispStat (AJRossini) </ul> <p>Changes/New Features in 5.1.13: <ul> <li>Version numbering finally all depending on the ./VERSION file, thanks to Martin Maechler. <li>Yet more fixes to SAS mode, thanks to Rich Heiberger. </ul> <p>Changes/New Features in 5.1.12: <ul> <li>Splus 5.1 stabilized, thanks to Martin Maechler, Bill Venables, Chuck Taylor, and others. <li>More fixes to SAS mode, thanks to Rodney Sparapani and Rich Heiberger. </ul> <p>Changes/New Features in 5.1.11: <ul> <li>More fixes to Stata mode, thanks to <a href="mailto:brendan@essex.ac.uk">Brendan Halpin</a>. <li>fixed bugs in ESS-elsewhere, thanks to many testers <li>README.SPLUS4WIN has DETAILED instructions for S-PLUS 2000, thanks to <a href="mailto:brahm@alum.mit.edu">David Brahm</a>. <li>Fixes to SAS mode, thanks to Rodney Sparapani </ul> <p>Changes/New Features in 5.1.10: <ul> <li>More fixes to Stata mode <li>primitive generic version of ESS-elsewhere <li>Small fixes to SAS/Stata. </ul> <p>Changes/New Features in 5.1.9: <ul> <li>Stata mode works <li>Literate Data Analysis using Noweb works </ul> <p>Changes/New Features in 5.1.8: <ul> <li>Bug fixes <li>R documentation mode defaults changed </ul> <p>Changes/New Features in 5.1.2: <ul> <li>able to use inferior iESS mode to communicate directly with a running S-Plus 4.x process using the Microsoft DDE protocol. We use the familiar (from Unix ESS) <kbd>C-c C-n</kbd> and related key sequences to send lines from the S-mode file to the inferior S process. We continue to edit S input files in <acronym>ESS[S]</acronym> mode and transcripts of previous S sessions in ESS Transcript mode. All three modes know the S language, syntax, and indentation patterns and provide the syntactic highlighting that eases the programming tasks. </ul> </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Credits"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Latest-version">Latest version</a>, Previous: <a rel="previous" accesskey="p" href="#New-features">New features</a>, Up: <a rel="up" accesskey="u" href="#Introduction">Introduction</a> </div> <h3 class="section">1.3 Authors of and contributors to ESS</h3> <p><a name="index-comint-6"></a><a name="index-authors-7"></a><a name="index-credits-8"></a> 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. <p>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. <p>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. <p>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. <p>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. <ul> <li>The multiple process code, and the idea for <code>ess-eval-line-and-next-line</code> are by Rod Ball. <li>Thanks to Doug Bates for many useful suggestions. <li>Thanks to Martin Maechler for reporting and fixing bugs, providing many useful comments and suggestions, and for maintaining the ESS mailing lists. <li>Thanks to Frank Ritter for updates, particularly the menu code, and invaluable comments on the manual. <li>Thanks to Ken'ichi Shibayama for his excellent indenting code, and many comments and suggestions. <li>Thanks to Aki Vehtari for adding interactive BUGS support. <li>Thanks to Brendan Halpin for bug-fixes and updates to Stata-mode. <li>Last, but definitely not least, thanks to the many ESS users and contributors to the ESS mailing lists. </ul> <p><em>ESS</em> version 5 is being developed and currently maintained by <ul> <li><!-- @uref{http://www.google.com/,A.J. Rossini} --> <a href="mailto:blindglobe@gmail.com">A.J. Rossini</a> <!-- --> <li><!-- @uref{http://www.sbm.temple.edu/departments/statistics/,Richard M. Heiberger} --> <a href="mailto:rmh@temple.edu">Richard M. Heiberger</a> <!-- --> <li><!-- @uref{http://www.ci.tuwien.ac.at/~hornik,Kurt Hornik} --> <a href="mailto:Kurt.Hornik@R-project.org">Kurt Hornik</a> <!-- --> <li><!-- @uref{http://stat.ethz.ch/people/maechler/,Martin Maechler} --> <a href="mailto:maechler@stat.math.ethz.ch">Martin Maechler</a> <!-- --> <li><!-- @uref{http://www.mcw.edu/pcor/rsparapa,Rodney A. Sparapani} --> <a href="mailto:rsparapa@mcw.edu">Rodney A. Sparapani</a> <!-- --> <li><!-- @uref{http://www.damtp.cam.ac.uk/user/eglen,Stephen Eglen} --> <a href="mailto:stephen@gnu.org">Stephen Eglen</a> <li><!-- @uref{http://www.ucs.mun.ca/~sluque,Sebastian P. Luque} --> <a href="mailto:spluque@gmail.com">Sebastian P. Luque</a> <li><!-- @uref{http://www.google.com,Henning Redestig} --> <a href="mailto:henning.red@googlemail.com">Henning Redestig</a> </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Latest-version"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Manual">Manual</a>, Previous: <a rel="previous" accesskey="p" href="#Credits">Credits</a>, Up: <a rel="up" accesskey="u" href="#Introduction">Introduction</a> </div> <h3 class="section">1.4 Getting the latest version of ESS</h3> <p>The latest released version of ESS is always available on the web at: <a href="http://ess.r-project.org">ESS web page</a> or <a href="http://lib.stat.cmu.edu/general/ESS/">StatLib</a> <!-- There no longer is an anonymous CVS repository for ESS, due to lack of --> <!-- interest, little demand, and problems with security. --> <!-- text below modified from R-admin.texi (thanks to Kurt for the tip). --> <p>The latest development version of ESS is available via <a href="https://svn.R-project.org/ESS/">https://svn.R-project.org/ESS/</a>, the ESS Subversion repository. If you have a Subversion client (see <a href="http://subversion.tigris.org/">http://subversion.tigris.org/</a>), you can download the sources using: <pre class="smallexample"> % svn checkout https://svn.r-project.org/ESS/trunk <var>path</var> </pre> <p class="noindent">which will put the ESS files into directory <var>path</var>. 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: <a href="https://svn.r-project.org/ESS/trunk">ESS SVN site</a>. However, please use a subversion client instead to minimize the load when retrieving. <p>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: <pre class="example"> (load "/path/to/ess-svn/lisp/ess-site.el") </pre> <p>Note that https is required, and that the SSL certificate for the Subversion server of the R project is <pre class="smallexample"> 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 </pre> <p class="noindent">(currently, there is no “trusted certificate”). You can accept this certificate permanently and will not be asked about it anymore. <!-- node-name, next, previous, up --> <div class="node"> <a name="Manual"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#Latest-version">Latest version</a>, Up: <a rel="up" accesskey="u" href="#Introduction">Introduction</a> </div> <h3 class="section">1.5 How to read this manual</h3> <p>If you need to install ESS, read <a href="#Installation">Installation</a> for details on what needs to be done before proceeding to the next chapter. <p>In this manual we use the standard notation for describing the keystrokes used to invoke certain commands. <kbd>C-<chr></kbd> means hold the CONTROL key while typing the character <chr>. <kbd>M-<chr></kbd> 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>. <p>All ESS commands can be invoked by typing <kbd>M-x command</kbd>. 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. <p>Some commands, such as <kbd>M-x R</kbd> can accept an optional `prefix' argument. To specify the prefix argument, you would type <kbd>C-u</kbd> before giving the command. e.g. If you type <kbd>C-u M-x R</kbd>, you will be asked for command line options that you wish to invoke the R process with. <p>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 <kbd>C-h f</kbd>. For example, if you type <kbd>C-h f ess-eval-region</kbd>, 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 <kbd>C-h m</kbd> within an ESS buffer. <p>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 <kbd>M-x customize-group RET ess RET</kbd> to get started.) <a href="#Customization">Customization</a> 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. <!-- node-name, next, previous, up --> <div class="node"> <a name="Installation"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Interactive-ESS">Interactive ESS</a>, Previous: <a rel="previous" accesskey="p" href="#Introduction">Introduction</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">2 Installing ESS on your system</h2> <p><a name="index-installation-9"></a> The following section details those steps necessary to get ESS running on your system. <ul class="menu"> <li><a accesskey="1" href="#Unix-installation">Unix installation</a>: Installing ESS on your Unix system <li><a accesskey="2" href="#Microsoft-Windows-installation">Microsoft Windows installation</a>: Installing ESS on your MS Windows system <li><a accesskey="3" href="#Requirements">Requirements</a>: emacs, Operating Systems and Statistical Packages </ul> <!-- FIXME: the following contains @node s *and* is also included by readme.texi --> <!-- which does *not* include 'requires.texi' --> <!-- ==> *must* give node pointer problems! --> <!-- @include inst_tar.texi --> <div class="node"> <a name="Unix-installation"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Microsoft-Windows-installation">Microsoft Windows installation</a>, Up: <a rel="up" accesskey="u" href="#Installation">Installation</a> </div> <!-- node-name, next, previous, up --> <h3 class="section">2.1 Unix installation</h3> <!-- THIS IS A REPLACEMENT FOR THE UNIX PORTION OF inst_tar.texi --> <p>For a <b>Unix or Unix-like installation</b>, please follow the next steps. Retrieve the latest tgz file (<samp><span class="file">ess-VERSION.tgz</span></samp>) from <a href="http://ess.r-project.org/index.php?Section=download">ESS downloads area</a>. <p><em>GNU Emacs Simple Instructions:</em> for recent versions of Emacs (22.x or higher) and ESS, the installation process is simple. <ol type=1 start=1> <li>Extract all the files from <samp><span class="file">ess-VERSION.tgz</span></samp> into the directory <samp><span class="file">PREFIX/site-lisp</span></samp> where <samp><span class="file">PREFIX</span></samp> is appropriate for GNU Emacs on your system; <samp><span class="file">PREFIX</span></samp> will most likely be either <samp><span class="file">/usr/share/emacs</span></samp> or <samp><span class="file">/usr/local/share/emacs</span></samp> <!-- which exists for packages like @ESS{} --> (on Mac OS X, <samp><span class="file">PREFIX</span></samp> will most likely be something like <samp><span class="file">/Applications/Emacs.app/Contents/Resources</span></samp>): <pre class="example"> GNU tar % gtar zxf ess-VERSION.tgz -C PREFIX/site-lisp Unix tar % gunzip < ess-VERSION.tgz | tar xf - -C PREFIX/site-lisp </pre> <li>Then, add the line <pre class="example"> (require 'ess-site) </pre> <p>to <samp><span class="file">~/.emacs</span></samp> and restart Emacs. <li>If you see a buffer named <samp><span class="file">*ESS*</span></samp>, then the simple instructions were most likely successful. If not, then read further. <li>It could be that you have an older version of Emacs, some other problem with your installation or you are not a sysadmin. Whatever the case, you may need to edit <samp><span class="file">ess-site.el</span></samp> manually. If that is the case, then you should create a directory just for <acronym>ESS</acronym> like <samp><span class="file">~/ess</span></samp> or <samp><span class="file">/usr/local/ess</span></samp> and unpack <acronym>ESS</acronym> there. That way, your changes to <samp><span class="file">ess-site.el</span></samp> will not be lost if you update Emacs later. <li>Replace the line above with <pre class="example"> (load "~/ess/ess-VERSION/lisp/ess-site") </pre> <p>in <samp><span class="file">~/.emacs</span></samp> and restart Emacs. <li>If you see a buffer named <samp><span class="file">*ESS*</span></samp>, then the manual instructions were most likely successful. If not, then send a query to <a href="mailto:ess-help@r-project.org">ess-help@r-project.org</a> explicitly describing your problem and your environment including operating system, Emacs version, <acronym>ESS</acronym> version, etc. </ol> <p><em>XEmacs Simple Instructions:</em> for recent versions of XEmacs (21.x or higher) and ESS, the installation process is simple. <ol type=1 start=1> <li>Extract all the files from <samp><span class="file">ess-VERSION.tgz</span></samp> when you are in the current working directory of <samp><span class="file">/usr/local/LOCATION/xemacs/site-packages</span></samp> which exists for packages like <acronym>ESS</acronym> where <samp><span class="file">LOCATION</span></samp> is <samp><span class="file">lib</span></samp> for legacy installations and <samp><span class="file">share</span></samp> now (and for Mac OS X create a link to it from the directory <samp><span class="file">/Applications/XEmacs.app/Contents/Resources/site-lisp</span></samp>): <pre class="example"> %prompt gtar zxf ess-VERSION.tgz # for GNU tar %prompt gunzip < ess-VERSION.tgz | tar xf - # for Unix tar </pre> <li>Then, add the line <pre class="example"> (require 'ess-site) </pre> <p>to <samp><span class="file">~/.xemacs/init.el</span></samp> and restart XEmacs. <li>If you see a buffer named <samp><span class="file">*ESS*</span></samp>, then the simple instructions were most likely successful. If not, then read further. <li>It could be that you have an older version of XEmacs, some other problem with your installation or you are not a sysadmin. Whatever the case, you may need to edit <samp><span class="file">ess-site.el</span></samp> manually. If that is the case, then you should create a directory just for <acronym>ESS</acronym> like <samp><span class="file">~/ess</span></samp> or <samp><span class="file">/usr/local/ess</span></samp> and unpack <acronym>ESS</acronym> there. That way, your changes to <samp><span class="file">ess-site.el</span></samp> will not be lost if you update XEmacs later. <li>Replace the line above with <pre class="example"> (load "~/ess/ess-VERSION/lisp/ess-site") </pre> <p>in <samp><span class="file">~/.xemacs/init.el</span></samp> and restart XEmacs. <li>If you see a buffer named <samp><span class="file">*ESS*</span></samp>, then the manual instructions were most likely successful. If not, then send a query to <a href="mailto:ess-help@r-project.org">ess-help@r-project.org</a> explicitly describing your problem and your environment including operating system, XEmacs version, <acronym>ESS</acronym> version, etc. </ol> <ol type=1 start=1> <li><b>(OPTIONAL) COMPILING E-LISP</b>: <p>Edit the default locations of <code>LISPDIR</code>, <code>INFODIR</code> and <code>ETCDIR</code> in Section 1 of <samp><span class="file">Makeconf</span></samp> (if you are using XEmacs, then edit the XEmacs subsection in Section 1). <p>You can compile those files by: <pre class="example"> make all </pre> <p>When that completes successfully, install the compiled files: <pre class="example"> make install </pre> </ol> <!-- @node Microsoft Windows installation, , Unix installation, Installation --> <div class="node"> <a name="Microsoft-Windows-installation"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Requirements">Requirements</a>, Previous: <a rel="previous" accesskey="p" href="#Unix-installation">Unix installation</a>, Up: <a rel="up" accesskey="u" href="#Installation">Installation</a> </div> <!-- node-name, next, previous, up --> <h3 class="section">2.2 Microsoft Windows installation</h3> <!-- THIS IS A REPLACEMENT FOR THE WINDOWS PORTION OF inst_tar.texi --> <p>For <b>Microsoft Windows installation</b>, please follow the next steps. Retrieve the latest zip file (<samp><span class="file">ess-VERSION.zip</span></samp>) from <a href="http://ess.r-project.org/index.php?Section=download">ESS downloads area</a>. <p><em>GNU Emacs Simple Instructions:</em> for recent versions of Emacs (22.x or higher) and ESS, the installation process is simple. <ol type=1 start=1> <li>Extract all the files from <samp><span class="file">ess-VERSION.zip</span></samp> (by double clicking on it and selecting “Extract all files” which launches the Folders Extraction Wizard) into an <samp><span class="file">ESS</span></samp> sub-directory of the <samp><span class="file">site-lisp</span></samp> directory that exists for packages like <acronym>ESS</acronym>. If GNU Emacs was installed in the default location, then this directory can be found somewhere like <samp><span class="file">C:\Program Files\GNU Emacs\emacs-22.x\site-lisp</span></samp> <li>Add the line <pre class="example"> (require 'ess-site) </pre> <p>to <samp><span class="file">~/.emacs</span></samp> and restart Emacs. <li>If you see a buffer named <samp><span class="file">*ESS*</span></samp>, then the simple instructions were most likely successful. If not, then read further. <li>It could be you have an older version of Emacs or some other problem with your installation. Either way, you may need to edit <samp><span class="file">C:\ess\ess-VERSION\lisp\ess-site.el</span></samp> manually. If that is the case, then you should create a directory just for <acronym>ESS</acronym> like <samp><span class="file">C:\ess</span></samp> and unpack <acronym>ESS</acronym> there. That way, your changes to <samp><span class="file">C:\ess\ess-VERSION\lisp\ess-site.el</span></samp> will not be lost if you update Emacs later. <li>Replace the line above with <pre class="example"> (load "C:/ess/ess-VERSION/lisp/ess-site") </pre> <p>in <samp><span class="file">~/.emacs</span></samp> and restart Emacs. <li>If you see a buffer named <samp><span class="file">*ESS*</span></samp>, then the manual instructions were most likely successful. If not, then send a query to <a href="mailto:ess-help@r-project.org">ess-help@r-project.org</a> explicitly describing your problem and your environment including operating system, Emacs version, <acronym>ESS</acronym> version, etc. </ol> <p><em>XEmacs Simple Instructions:</em> 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. <ol type=1 start=1> <li>Extract all the files from <samp><span class="file">ess-VERSION.zip</span></samp> (by double clicking on it and selecting “Extract all files” which launches the Folders Extraction Wizard) into the <samp><span class="file">site-packages</span></samp> directory that exists for packages like <acronym>ESS</acronym>. If XEmacs was installed in the default location, then this directory can be found at <samp><span class="file">C:\Program Files\XEmacs\site-packages</span></samp>. <li>XEmacs requires the <code>HOME</code> environment variable to be defined. You can create it by visiting the following dialog: <code>My Computer->Control Panel->System->Advanced->Environment Variables</code> In the User variables window, press New. And create a variable named <code>HOME</code> with a value something like (you must use forward slashes <code>/</code> rather than backslashes <code>\</code>) <code>c:/Documents and Settings/%USERNAME%/Application Data</code>. Then press OK for that window and press OK for the main window. <em>If you also have GNU Emacs installed, GNU Emacs will recognize </em><code>HOME</code><em> and expand </em><code>~</code><em> accordingly.</em> <li>Now launch XEmacs and do a <code>C-x C-f</code> followed by a <code>~</code>. From the Subdir menu, select Create Directory, and enter <code>.xemacs</code> <li>Add the line <pre class="example"> (require 'ess-site) </pre> <p>to <samp><span class="file">~/.xemacs/init.el</span></samp> and restart XEmacs. <li>If you see a buffer named <samp><span class="file">*ESS*</span></samp>, then the simple instructions were most likely successful. If not, then read further. <li>It could be you have an older version of XEmacs or some other problem with your installation. Either way, you may need to edit <samp><span class="file">C:\ess\ess-VERSION\lisp\ess-site.el</span></samp> manually. If that is the case, then you should create a directory just for <acronym>ESS</acronym> like <samp><span class="file">C:\ess</span></samp> and unpack <acronym>ESS</acronym> there. That way, your changes to <samp><span class="file">C:\ess\ess-VERSION\lisp\ess-site.el</span></samp> will not be lost if you update XEmacs later. <li>Replace the line above with <pre class="example"> (load "C:/ess/ess-VERSION/lisp/ess-site") </pre> <p>in <samp><span class="file">~/.xemacs/init.el</span></samp> and restart XEmacs. <li>If you see a buffer named <samp><span class="file">*ESS*</span></samp>, then the manual instructions were most likely successful. If not, then send a query to <a href="mailto:ess-help@r-project.org">ess-help@r-project.org</a> explicitly describing your problem and your environment including operating system, XEmacs version, <acronym>ESS</acronym> version, etc. </ol> <p>Now, you should be ready to use <acronym>ESS</acronym>. 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. <p>To run statistical processes under <acronym>ESS</acronym>, Windows users will need to make sure that the directories for the software they will be using is in the PATH environment variable. <p>On Windows NT/2000/XP, add the directories to the PATH using the <code>My Computer->Control Panel->System->Advanced->Environment Variables</code> 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</code> and not the long version with embedded blanks as this may cause problems. Also, make sure to use backslashes <code>\</code> since Windows requires them. <p>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): <pre class="example"> (setq inferior-R-program-name "c:/progra~1/R/R-2.2.1/bin/Rterm.exe") </pre> <p>This assumes that you have installed R-2.2.1 in the default location. Change the path otherwise to point to other locations. <p>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): <pre class="example"> (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") </pre> <p>The above example uses the default location of S-PLUS in <code>c:\progra~1\Insightful</code>. Please note that <acronym>ESS</acronym> considers S-PLUS 6, 7, and 8 to be variants of S+6. <p>These users may also need to modify the emacs variable <code>ess-SHOME-versions</code> to match their installation in order to get the full set of S-PLUS versions on their machine into the <acronym>ESS</acronym> menu. <p>To start the S-PLUS [678].x GUI from ESS under emacs: <ol type=1 start=1> <li>If you use Cygwin bash as your primary shell, then <pre class="example"> M-x S (or <code>M-x S+6</code>). </pre> <li>If you use the MSDOS prompt window as your primary shell, then <pre class="example"> M-x S+6-msdos </pre> </ol> 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, <samp><span class="file">myfile.s</span></samp>) to the S-PLUS Commands Window with the <code>C-c C-n</code> or <code>C-c C-r</code> keys. (If you are still using S-PLUS 4.x or 2000,\ then use <code>M-x S+4</code> or <code>M-x S+4-msdos</code>.) <p>To start an S-PLUS [678].x session inside an emacs buffer—and without the S-PLUS GUI: <pre class="example"> M-x Sqpe (or <code>M-x Sqpe+6</code>). </pre> <p>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, <samp><span class="file">myfile.s</span></samp>) to the *S+6* buffer with the <code>C-c C-n</code> or <code>C-c C-r</code> keys. Interactive graphics are available with Sqpe by using the java library supplied with S-PLUS 6.1 and newer releases. Enter the commands: <pre class="example"> library(winjava) java.graph() </pre> <p>Graphs can be saved from the <code>java.graph</code> device in several formats, but not PostScript. If you need a PostScript file you will need to open a separate <code>postscript</code> device. (If you are still using S-PLUS 4.x or 2000, then use <code>M-x Sqpe+4</code>.) <p>To connect to an already running S-PLUS GUI (started, for example, from the S-PLUS icon): <pre class="example"> M-x S+6-existing </pre> <p>or <pre class="example"> M-x S+6-msdos-existing </pre> <p>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, <samp><span class="file">myfile.s</span></samp>) to the S-PLUS Commands Window with the <code>C-c C-n</code> or <code>C-c C-r</code> keys. (If you are still using S-PLUS 4.x or 2000, then use <code>M-x S+4-existing</code> or <code>M-x S+4-msdos-existing</code>.) <p>If you wish to run R, you can start it with: <pre class="example"> M-x R </pre> <p>XLispStat can not currently be run with <pre class="example"> M-x XLS </pre> <p>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. <div class="node"> <a name="Requirements"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#Microsoft-Windows-installation">Microsoft Windows installation</a>, Up: <a rel="up" accesskey="u" href="#Installation">Installation</a> </div> <!-- node-name, next, previous, up --> <h3 class="section">2.3 Requirements</h3> <p>ESS is most likely to work with current/recent versions of the following statistical packages: R/S-PLUS, SAS, Stata, OpenBUGS and JAGS. <p>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). <p>To build the PDF documentation, you will need a version of TeX Live or texinfo that includes texi2dvi (BEWARE: recent TeX Live, and some texinfo RPMs, do NOT include texi2dvi). <!-- ESS has been tested with --> <!-- @itemize @bullet --> <!-- @item R >=0.49 --> <!-- @item S-PLUS 3.3-4, 4.5, 2000, 5.0-1, 6.0-2, 7.0, 8.0 --> <!-- @item S4 --> <!-- @item SAS >=9.1 --> <!-- @item BUGS 0.5, 0.6 --> <!-- @item JAGS 1.0 --> <!-- @item Stata >=10.0 (command line only) --> <!-- @c is anyone still using this? @item XLispStat >=3.50 --> <!-- @end itemize --> <!-- on the following platforms --> <!-- @itemize @bullet --> <!-- @item Linux/x86 (all but BUGS) --> <!-- @item Solaris/x86 (all but BUGS and S-PLUS) --> <!-- @c cannot confirm this right now @item SGI (all) --> <!-- @item MS Windows 98/NT/2000/XP (R, S-PLUS, SAS interactive only, and BUGS) --> <!-- @item Apple Mac OS X 10.4-5 (R, JAGS, Stata) --> <!-- @end itemize --> <!-- with the following versions of emacs --> <!-- @itemize @bullet --> <!-- @item GNU Emacs 20.3-7, 21.1, 21.3-4, 22.1 --> <!-- @item XEmacs 21.4.0-8, 21.4.9-13@footnote{ --> <!-- require the files.el patch to revert-buffer for the Local Variables --> <!-- updating problem}, 21.4.14-15, 21.4.17-22 (betas not supported, but 21.5.23+ may work) --> <!-- @c @item GNU Emacs <20.3 and XEmacs <21.0@footnote{These releases of emacs are no --> <!-- @c longer supported, so an upgrade is recommended if you plan to use ESS. --> <!-- @c If you have GNU Emacs 19.29, see @xref{Unix installation}. Also, note --> <!-- @c that the `custom' library bundled with Emacs 19.34 is too _old_, its API is --> <!-- @c incompatible with the `new custom' bundled with recent Emacsen. --> <!-- @c The `new custom' for Emacs 19.34 is available for download --> <!-- @c @uref{ftp://ftp.dina.kvl.dk/pub/Staff/Per.Abrahamsen/custom/custom-1.9962.tar.gz, here}.} --> <!-- @end itemize --> <!-- node-name, next, previous, up --> <div class="node"> <a name="Interactive-ESS"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Entering-commands">Entering commands</a>, Previous: <a rel="previous" accesskey="p" href="#Installation">Installation</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">3 Interacting with statistical programs</h2> <p>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. <!-- node-name, next, previous, up --> <ul class="menu"> <li><a accesskey="1" href="#Starting-up">Starting up</a> <li><a accesskey="2" href="#Multiple-ESS-processes">Multiple ESS processes</a> <li><a accesskey="3" href="#ESS-processes-on-Remote-Computers">ESS processes on Remote Computers</a> <li><a accesskey="4" href="#S_002belsewhere-and-ESS_002delsewhere">S+elsewhere and ESS-elsewhere</a> <li><a accesskey="5" href="#Customizing-startup">Customizing startup</a> </ul> <div class="node"> <a name="Starting-up"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Multiple-ESS-processes">Multiple ESS processes</a>, Previous: <a rel="previous" accesskey="p" href="#Interactive-ESS">Interactive ESS</a>, Up: <a rel="up" accesskey="u" href="#Interactive-ESS">Interactive ESS</a> </div> <h3 class="section">3.1 Starting an ESS process</h3> <p><a name="index-starting-ESS-10"></a><a name="index-running-S-11"></a> To start an S session on Unix or on Windows when you use the Cygwin bash shell, simply type <kbd>M-x S RET</kbd>. <p>To start an S session on Windows when you use the MSDOS prompt shell, simply type <kbd>M-x S+6-msdos RET</kbd>. <p><a name="index-S-12"></a> <a name="index-ESS-process-directory-13"></a><a name="index-starting-directory-14"></a><a name="index-working-directory-15"></a><a name="index-directories-16"></a> S will then (by default) ask the question <pre class="example"> S starting data directory? </pre> <p class="noindent">Enter the name of the directory you wish to start S from (that is, the directory you would have <code>cd</code>'d to before starting S from the shell). This directory should have a <samp><span class="file">.Data</span></samp> subdirectory. <p>You will then be popped into a buffer <a name="index-ESS-process-buffer-17"></a><a name="index-process-buffer-18"></a>with name ‘<samp><span class="samp">*S*</span></samp>’ which will be used for interacting with the ESS process, and you can start entering commands. <!-- node-name, next, previous, up --> <div class="node"> <a name="Multiple-ESS-processes"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS-processes-on-Remote-Computers">ESS processes on Remote Computers</a>, Previous: <a rel="previous" accesskey="p" href="#Starting-up">Starting up</a>, Up: <a rel="up" accesskey="u" href="#Interactive-ESS">Interactive ESS</a> </div> <h3 class="section">3.2 Running more than one ESS process</h3> <p><a name="index-Multiple-ESS-processes-19"></a> 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 <a name="index-process-names-20"></a>(process 1) is simply named (using S-PLUS as an example) ‘<samp><span class="samp">S+3:1</span></samp>’. <!-- You may start a new process by passing a numeric argument to --> <!-- @kbd{M-x S}. For example, typing @kbd{ESC 2 M-x S} starts up --> <!-- an ESS process with name @samp{S2}, in a buffer whose name --> <!-- is initially @samp{*S2*}. --> The name of the process is shown in the mode line in square brackets (for example, ‘<samp><span class="samp">[S+3:2]</span></samp>’); this is useful if the process buffer is renamed. Without a prefix argument, <kbd>M-x S</kbd> starts a new ESS process, using the first available process number. With a prefix argument (for R), <kbd>C-u M-x R</kbd> allows for the specification of command line options. <p><a name="index-ess_002drequest_002da_002dprocess-21"></a>You can switch to any active ESS process with the command ‘<samp><span class="samp">M-x ess-request-a-process</span></samp>’. 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. <!-- SJE - commented outl the default behaviour now is to label *S* rather --> <!-- than *S:1*. --> <!-- @vindex ess-plain-first-buffername --> <!-- For the predecessor to ESS (S-mode 4.8), the initial process was not --> <!-- visibly numbered, i.e. S instead of S1 was used in the mode-line. To --> <!-- obtain this behavior, set the variable @code{ess-plain-first-buffername} --> <!-- to @code{t}. See @file{ess-site} for how to set this for all users. --> <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS-processes-on-Remote-Computers"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#S_002belsewhere-and-ESS_002delsewhere">S+elsewhere and ESS-elsewhere</a>, Previous: <a rel="previous" accesskey="p" href="#Multiple-ESS-processes">Multiple ESS processes</a>, Up: <a rel="up" accesskey="u" href="#Interactive-ESS">Interactive ESS</a> </div> <h3 class="section">3.3 ESS processes on Remote Computers</h3> <p><a name="index-Remote-Computers-22"></a><a name="index-ess_002dremote-23"></a><a name="index-ESS_002delsewhere-24"></a><a name="index-S_002belsewhere-25"></a> 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. <ol type=1 start=1> <li>Start a new telnet or ssh buffer and connect to the remote computer (e.g. use ‘<samp><span class="samp">M-x telnet</span></samp>’ or ‘<samp><span class="samp">M-x ssh</span></samp>’; ssh.el is available at <a href="ftp://ftp.splode.com/pub/users/friedman/emacs-lisp/ssh.el">ftp://ftp.splode.com/pub/users/friedman/emacs-lisp/ssh.el</a>). <li>Start the ESS process on the remote machine, for example with one of the commands ‘<samp><span class="samp">Splus</span></samp>’, or ‘<samp><span class="samp">R</span></samp>’, or ‘<samp><span class="samp">sas -stdio</span></samp>’. <li>Enter the ESS command ‘<samp><span class="samp">M-x ess-remote</span></samp>’. You will be prompted for a program name. Enter ‘<samp><span class="samp">sp6</span></samp>’ or ‘<samp><span class="samp">r</span></samp>’ or ‘<samp><span class="samp">sas</span></samp>’ or another valid name. Your telnet process is now known to ESS. All the usual ESS commands (‘<samp><span class="samp">C-c C-n</span></samp>’ and its relatives) now work with the S language processes. For SAS you need to use a different command ‘<samp><span class="samp">C-c i</span></samp>’ (that is a regular ‘<samp><span class="samp">i</span></samp>’, not a ‘<samp><span class="samp">C-i</span></samp>’) to send lines from your <samp><span class="file">myfile.sas</span></samp> to the remote SAS process. ‘<samp><span class="samp">C-c i</span></samp>’ sends lines over invisibly. <!-- and lets SAS display them formatted correctly as in a SAS log file. --> With ess-remote you get teletype behavior—the data input, the log, and the listing all appear in the same buffer. To make this work, you need to end every PROC and DATA step with a "RUN;" statement. The "RUN;" statement is what tells SAS that it should process the preceding input statements. <li>Graphics (interactive) on the remote machine. If you run X11 (See <a href="#X11">X11</a>, X-windows) on both the local and remote machines then you should be able to display the graphs locally by setting the ‘<samp><span class="samp">DISPLAY</span></samp>’ environment variable appropriately. Windows users can download ‘<samp><span class="samp">xfree86</span></samp>’ from cygwin. <li>Graphics (static) on the remote machine. If you don't run the X window system on the local machine, then you can write graphics to a file on the remote machine, and display the file in a graphics viewer on the local machine. Most statistical software can write one or more of postscript, GIF, or JPEG files. Depending on the versions of emacs and the operating system that you are running, emacs itself may display ‘<samp><span class="samp">.gif</span></samp>’ and ‘<samp><span class="samp">.jpg</span></samp>’ files. Otherwise, a graphics file viewer will be needed. Ghostscript/ghostview may be downloaded to display ‘<samp><span class="samp">.ps</span></samp>’ and ‘<samp><span class="samp">.eps</span></samp>’ files. Viewers for GIF and JPEG are usually included with operating systems. See <a href="#ESS_0028SAS_0029_002d_002dFunction-keys-for-batch-processing">ESS(SAS)–Function keys for batch processing</a>, for more information on using the F12 key for displaying graphics files with SAS. </ol> <p>Should you or a colleague inadvertently start a statistical process in an ordinary ‘<samp><span class="samp">*shell*</span></samp>’ buffer, the ‘<samp><span class="samp">ess-remote</span></samp>’ command can be used to convert it to an ESS buffer and allow you to use the ESS commands with it. <p>We have two older commands, now deprecated, for accessing ESS processes on remote computers. See <a href="#S_002belsewhere-and-ESS_002delsewhere">S+elsewhere and ESS-elsewhere</a>. <!-- node-name, next, previous, up --> <div class="node"> <a name="S+elsewhere-and-ESS-elsewhere"></a> <a name="S_002belsewhere-and-ESS_002delsewhere"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Customizing-startup">Customizing startup</a>, Previous: <a rel="previous" accesskey="p" href="#ESS-processes-on-Remote-Computers">ESS processes on Remote Computers</a>, Up: <a rel="up" accesskey="u" href="#Interactive-ESS">Interactive ESS</a> </div> <h3 class="section">3.4 S+elsewhere and ESS-elsewhere</h3> <p>These commands are now deprecated. We recommend ‘<samp><span class="samp">ess-remote</span></samp>’. We have two versions of the elsewhere function. ‘<samp><span class="samp">S+elsewhere</span></samp>’ is specific for the S-Plus program. The more general function ‘<samp><span class="samp">ESS-elsewhere</span></samp>’ is not as stable. <ol type=1 start=1> <li>Enter ‘<samp><span class="samp">M-x S+elsewhere</span></samp>’. You will be prompted for a starting directory. I usually give it my project directory on the local machine, say ‘<samp><span class="samp">~myname/myproject/</span></samp>’ <p>Or enter ‘<samp><span class="samp">M-x ESS-elsewhere</span></samp>’. 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 ‘<samp><span class="samp">~myname/myproject/</span></samp>’ <li>The ‘<samp><span class="samp">*S+3*</span></samp>’ buffer will appear with a prompt from the local operating system (the unix prompt on a unix workstation or with cygwin bash on a PC, or the msdos prompt on a PC without bash). emacs may freeze because the cursor is at the wrong place. Unfreeze it with ‘<samp><span class="samp">C-g</span></samp>’ then move the cursor to the end with ‘<samp><span class="samp">M-></span></samp>’. With ‘<samp><span class="samp">S+elsewhere</span></samp>’ the buffer name is based on the name of the ESS program. <li>Enter ‘<samp><span class="samp">telnet myname@other.machine</span></samp>’ (or ‘<samp><span class="samp">ssh myname@other.machine</span></samp>’). You will be prompted for your password on the remote machine. Use ‘<samp><span class="samp">M-x send-invisible</span></samp>’ before typing the password itself. <li>Before starting the ESS process, type ‘<samp><span class="samp">stty -echo nl</span></samp>’ at the unix prompt. The ‘<samp><span class="samp">-echo</span></samp>’ turns off the echo, the ‘<samp><span class="samp">nl</span></samp>’ turns off the newline that you see as ‘<samp><span class="samp">^M</span></samp>’. <li>You are now talking to the unix prompt on the other machine in the ‘<samp><span class="samp">*S+3*</span></samp>’ buffer. cd into the directory for the current project and start the ESS process by entering ‘<samp><span class="samp">Splus</span></samp>’ or ‘<samp><span class="samp">R</span></samp>’ or ‘<samp><span class="samp">sas -stdio</span></samp>’ as appropriate. If you can login remotely to your Windows 2000, then you should be able to run ‘<samp><span class="samp">Sqpe</span></samp>’ on the Windows machine. I haven't tested this and noone has reported their tests to me. You will not be able to run the GUI through this text-only connection. <li>Once you get the S or R or SAS prompt, then you are completely connected. All the ‘<samp><span class="samp">C-c C-n</span></samp>’ and related commands work correctly in sending commands from ‘<samp><span class="samp">myfile.s</span></samp>’ or ‘<samp><span class="samp">myfile.r</span></samp>’ on the PC to the ‘<samp><span class="samp">*S+3*</span></samp>’ buffer running the S or R or SAS program on the remote machine. <li>Graphics on the remote machine works fine. If you run the X window system on the remote unix machine you should be able to display them in ‘<samp><span class="samp">xfree86</span></samp>’ on your PC. If you don't run X11, then you can write graphics to the postscript device and copy it to your PC with dired and display it with ghostscript. </ol> <!-- node-name, next, previous, up --> <div class="node"> <a name="Customizing-startup"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#S_002belsewhere-and-ESS_002delsewhere">S+elsewhere and ESS-elsewhere</a>, Up: <a rel="up" accesskey="u" href="#Interactive-ESS">Interactive ESS</a> </div> <h3 class="section">3.5 Changing the startup actions</h3> <p>If you do not wish ESS to prompt for a starting directory when starting a new process, set the variable <code>ess-ask-for-ess-directory</code> to <a name="index-ess_002dask_002dfor_002dess_002ddirectory-26"></a><code>nil</code>. In this case, the starting directory will be set using one of the following methods: <ol type=1 start=1> <li>If the variable <code>ess-directory-function</code> stores the name of a function, the value returned by this function is used. The default for this variable is nil. <li>Otherwise, if the variable <code>ess-directory</code> stores the name of a directory (ending in a slash), this value is used. The default for this variable is nil. <li>Otherwise, the working directory of the current buffer is used. </ol> <p>If <code>ess-ask-for-ess-directory</code> has a non-<code>nil</code> value (as it does by default) then the value determined by the above rules provides the default when prompting for the starting directory. Incidentally, <code>ess-directory</code> is an ideal variable to set in <code>ess-pre-run-hook</code>. <p>If you like to keep a record of your S sessions, set the variable <code>ess-ask-about-transfile</code> to <code>t</code>, and you will be asked for a filename for the transcript before the ESS process starts. <div class="defun"> — User Option: <b>ess-ask-about-transfile</b><var><a name="index-ess_002dask_002dabout_002dtransfile-27"></a></var><br> <blockquote><p>If non-<code>nil</code>, as for a file name in which to save the session transcript. </p></blockquote></div> <p><a name="index-transcript-file-28"></a>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 ‘<samp><span class="samp">.St</span></samp>’); 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 <a href="#Saving-transcripts">Saving transcripts</a>.) <p>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 <code>inferior-ess-program</code>. <a name="index-inferior_002dess_002dprogram-29"></a>If you need to pass any arguments to this program, they may be specified in the variable <code>inferior-</code><var>S_program_name</var><code>-args</code> (e.g. if <code>inferior-ess-program</code> is <code>"S+"</code> then the variable to set is <code>inferior-S+-args</code>. <a name="index-arguments-to-S-program-30"></a>It is not normally necessary to pass arguments to the S program; in particular do not pass the ‘<samp><span class="samp">-e</span></samp>’ option to <code>Splus</code>, since ESS provides its own command history mechanism. <p>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 <code>inferior-ess-own-frame</code>. Alternatively, change <code>inferior-ess-same-window</code> if you wish the process to appear within another window of the current frame. <!-- node-name, next, previous, up --> <div class="node"> <a name="Entering-commands"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Transcript-Mode">Transcript Mode</a>, Previous: <a rel="previous" accesskey="p" href="#Interactive-ESS">Interactive ESS</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">4 Interacting with the ESS process</h2> <p><a name="index-entering-commands-31"></a><a name="index-commands-32"></a><a name="index-sending-input-33"></a> 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 <a href="emacs.html#Shell-Mode">Shell Mode</a>). Command-line completion of S objects and a number of `hot keys' for commonly-used S commands are also provided for ease of typing. <ul class="menu"> <li><a accesskey="1" href="#Command_002dline-editing">Command-line editing</a>: Entering commands and fixing mistakes <li><a accesskey="2" href="#Completion">Completion</a>: Completion of object names <li><a accesskey="3" href="#Completion-details">Completion details</a>: Advanced completion concepts <li><a accesskey="4" href="#Transcript">Transcript</a>: Manipulating the transcript <li><a accesskey="5" href="#Command-History">Command History</a>: Command History <li><a accesskey="6" href="#History-expansion">History expansion</a>: References to historical commands <li><a accesskey="7" href="#Hot-keys">Hot keys</a>: Hot keys for common commands <li><a accesskey="8" href="#Statistical-Process-running-in-ESS_003f">Statistical Process running in ESS?</a> <li><a accesskey="9" href="#Emacsclient">Emacsclient</a>: Using emacsclient <li><a href="#Other">Other</a>: Other commands provided by inferior-ESS </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Command-line-editing"></a> <a name="Command_002dline-editing"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Completion">Completion</a>, Previous: <a rel="previous" accesskey="p" href="#Entering-commands">Entering commands</a>, Up: <a rel="up" accesskey="u" href="#Entering-commands">Entering commands</a> </div> <h3 class="section">4.1 Entering commands and fixing mistakes</h3> <p><a name="index-command_002dline-editing-34"></a> Sending a command to the ESS process is as simple as typing it in and pressing the <RETURN> key: <ul> <li><kbd>RET</kbd> (<code>inferior-ess-send-input</code>) <br> <a name="index-inferior_002dess_002dsend_002dinput-35"></a>Send the command on the current line to the ESS process. </ul> <p>If you make a typing error before pressing <kbd>RET</kbd> all the usual Emacs editing commands are available to correct it (see <a href="emacs.html#Basic">Basic</a>). 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. <p>ESS provides some other commands which are useful for fixing mistakes: <ul> <li><kbd>C-c C-w</kbd> (<code>backward-kill-word</code>) <br> <a name="index-backward_002dkill_002dword-36"></a>Deletes the previous word (such as an object name) on the command line. <li><kbd>C-c C-u</kbd> (<code>comint-kill-input</code>) <br> <a name="index-comint_002dkill_002dinput-37"></a>Deletes everything from the prompt to point. Use this to abandon a command you have not yet sent to the ESS process. <li><kbd>C-c C-a</kbd> (<code>comint-bol</code>) <br> <a name="index-comint_002dbol-38"></a>Move to the beginning of the line, and then skip forwards past the prompt, if any. </ul> <p>See <a href="emacs.html#Shell-Mode">Shell Mode</a>, for other commands relevant to entering input. <!-- node-name, next, previous, up --> <div class="node"> <a name="Completion"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Completion-details">Completion details</a>, Previous: <a rel="previous" accesskey="p" href="#Command_002dline-editing">Command-line editing</a>, Up: <a rel="up" accesskey="u" href="#Entering-commands">Entering commands</a> </div> <h3 class="section">4.2 Completion of object names</h3> <p><a name="index-completion-of-object-names-39"></a><a name="index-command_002dline-completion-40"></a> 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 <em>completes</em> the object name; if the cursor is following a file name <kbd>TAB</kbd> completes the file name. <ul> <li><kbd>TAB</kbd> (<code>comint-dynamic-complete</code>) <br> <a name="index-comint_002ddynamic_002dcomplete-41"></a>Complete the S object name or filename before point. </ul> <p>When the cursor is just after a partially-completed object name, pressing <TAB> provides completion in a similar fashion to <code>tcsh</code> <a name="index-tcsh-42"></a>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 <code>search()</code> command <a name="index-search_0028_0029-43"></a>along with the component objects of attached data frames <a name="index-data-frames-44"></a>(if your version of S supports them). <p>For example, consider the three functions (available in Splus version 3.0) called <code>binomplot()</code>, <code>binom.test()</code> and <code>binomial()</code>. Typing <kbd>bin TAB</kbd> after the S prompt will insert the characters ‘<samp><span class="samp">om</span></samp>’, completing the longest prefix (‘<samp><span class="samp">binom</span></samp>’) which distinguishes these three commands. Pressing <kbd>TAB</kbd> once more provides a list of the three commands which have this prefix, allowing you to add more characters (say, ‘<samp><span class="samp">.</span></samp>’) which specify the function you desire. After entering more characters pressing <kbd>TAB</kbd> 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 <kbd>M-?</kbd>. <ul> <li><kbd>M-?</kbd> (<code>ess-list-object-completions</code>) <br> <a name="index-ess_002dlist_002dobject_002dcompletions-45"></a>List all possible completions of the object name at point. </ul> <p>ESS also provides completion over the components of named lists accessed using the ‘<samp><span class="samp">$</span></samp>’ 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 ‘<samp><span class="samp">$</span></samp>’ and press <kbd>TAB</kbd> to see the names of existing list components for that object. <a name="index-lists_002c-completion-on-46"></a><a name="index-completion-on-lists-47"></a> <a name="index-completion-on-file-names-48"></a>Completion is also provided over file names, which is particularly useful when using S functions such as <code>get()</code> or <code>scan()</code> which require fully expanded file names. Whenever the cursor is within an S string, pressing <kbd>TAB</kbd> completes the file name before point. Since ESS 5.11, it no longer also expands any ‘<samp><span class="samp">~</span></samp>’ or environment variable references. <p>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 <a href="#History-expansion">History expansion</a>. <!-- node-name, next, previous, up --> <div class="node"> <a name="Completion-details"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Transcript">Transcript</a>, Previous: <a rel="previous" accesskey="p" href="#Completion">Completion</a>, Up: <a rel="up" accesskey="u" href="#Entering-commands">Entering commands</a> </div> <h3 class="section">4.3 Completion details</h3> <p>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 <a name="index-ess_002dchange_002dsp_002dregexp-49"></a><a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a> 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. <p>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 <code>objects()</code> command on every element of the search list. <!-- On some systems, however, this can be rather slow; it's doubly --> <!-- frustrating when you consider that most of the directories on the search --> <!-- list are the standard @Sl{} libraries, which never change anyway! When --> <!-- ESS was installed, a database of the standard object names should have --> <!-- been created which should speed up this process at the start of an S --> <!-- session; if it has not been created you will get a warning like --> <!-- `S-namedb.el does not exist'. @xref{Installation}, for information on --> <!-- how to create this database. --> <p>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 <strong>know</strong> is there), the command <kbd>M-x ess-resynch</kbd> <a name="index-ess_002dresynch-50"></a>forces the <em>entire</em> cache to be refreshed, which should fix the problem. <!-- node-name, next, previous, up --> <div class="node"> <a name="Transcript"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Command-History">Command History</a>, Previous: <a rel="previous" accesskey="p" href="#Completion-details">Completion details</a>, Up: <a rel="up" accesskey="u" href="#Entering-commands">Entering commands</a> </div> <h3 class="section">4.4 Manipulating the transcript</h3> <p>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 <a name="index-transcript-51"></a>move back up through the buffer, to look at the output from previous commands for example. <p>Within the process buffer, a paragraph <a name="index-paragraphs-in-the-process-buffer-52"></a>is defined as the prompt, the command after the prompt, and the output from the command. Thus <kbd>M-{</kbd> and <kbd>M-}</kbd> move you backwards and forwards, respectively, through commands in the transcript. A particularly useful command is <kbd>M-h</kbd> (<code>mark-paragraph</code>) which will allow you to mark a command and its entire output (for deletion, perhaps). For more information about paragraph commands, see <a href="emacs.html#Paragraphs">Paragraphs</a>. <p>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 (‘<samp><span class="samp">^L</span></samp>’) character. Thus pages in the ESS <a name="index-pages-in-the-process-buffer-53"></a>process buffer correspond to ESS sessions. Thus, for example, you may use <kbd>C-x [</kbd> and <kbd>C-x ]</kbd> to move backward and forwards through ESS sessions in a single ESS process buffer. For more information about page commands, see <a href="emacs.html#Pages">Pages</a>. <ul class="menu"> <li><a accesskey="1" href="#Last-command">Last command</a>: Manipulating the output from the last command <li><a accesskey="2" href="#Process-buffer-motion">Process buffer motion</a>: Viewing older commands <li><a accesskey="3" href="#Transcript-resubmit">Transcript resubmit</a>: Re-submitting commands from the transcript <li><a accesskey="4" href="#Saving-transcripts">Saving transcripts</a>: Keeping a record of your S session </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Last-command"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Process-buffer-motion">Process buffer motion</a>, Previous: <a rel="previous" accesskey="p" href="#Transcript">Transcript</a>, Up: <a rel="up" accesskey="u" href="#Transcript">Transcript</a> </div> <h4 class="subsection">4.4.1 Manipulating the output from the last command</h4> <p>Viewing the output of the command you have just entered is a common occurrence and ESS provides a number of facilities for doing this. <!-- Within the ESS process buffer, the variable @code{scroll-step} --> <!-- @vindex scroll-step --> <!-- is set to 4 (you can redefine this using @code{inferior-ess-mode-hook} --> <!-- @vindex inferior-ess-hook --> <!-- if you wish - @pxref{Hooks},) so that the cursor is usually near the --> <!-- bottom of the window. --> 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 <ul> <li><kbd>C-c C-e</kbd> (<code>comint-show-maximum-output</code>) <br> <a name="index-comint_002dshow_002dmaximum_002doutput-54"></a>Move to the end of the buffer, and place cursor on bottom line of window. </ul> <p class="noindent">to make more of the last output visible. (To make this happen automatically for all inputs, set the variable <code>comint-scroll-to-bottom-on-input</code> to <code>t</code>.) <p>If the first part of the output is still obscured, use <a name="index-reading-long-command-outputs-55"></a> <ul> <li><kbd>C-c C-r</kbd> (<code>comint-show-output</code>) <br> <a name="index-comint_002dshow_002doutput-56"></a>Moves cursor to the previous command line and and places it at the top of the window. </ul> <p class="noindent">to view it. Finally, if you want to discard the last command output altogether, use <ul> <li><kbd>C-c C-o</kbd> (<code>comint-kill-output</code>) <br> <a name="index-comint_002dkill_002doutput-57"></a><a name="index-deleting-output-58"></a>Deletes everything from the last command to the current prompt. </ul> <p class="noindent">to delete it. Use this command judiciously to keep your transcript to a more manageable size. <!-- node-name, next, previous, up --> <div class="node"> <a name="Process-buffer-motion"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Transcript-resubmit">Transcript resubmit</a>, Previous: <a rel="previous" accesskey="p" href="#Last-command">Last command</a>, Up: <a rel="up" accesskey="u" href="#Transcript">Transcript</a> </div> <h4 class="subsection">4.4.2 Viewing older commands</h4> <p>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: <ul> <li><kbd>C-c C-p</kbd> (<code>comint-previous-input</code>) <br> <a name="index-comint_002dprevious_002dinput-59"></a>Moves point to the preceding command in the process buffer. <li><kbd>C-c C-n</kbd> (<code>comint-next-input</code>) <br> <a name="index-comint_002dnext_002dinput-60"></a>Moves point to the next command in the process buffer. </ul> <p class="noindent">Note that these two commands are analogous to <kbd>C-p</kbd> and <kbd>C-n</kbd> but apply to command lines rather than text lines. And just like <kbd>C-p</kbd> and <kbd>C-n</kbd>, passing a prefix argument to these commands means to move to the <var>ARG</var>'th next (or previous) command. (These commands are also discussed in <a href="emacs.html#Shell-History-Copying">Shell History Copying</a>.) <p>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 <a href="emacs.html#Regexps">Syntax of Regular Expression</a>), and then moves to the next (previous) command matching the pattern. <ul> <li><code>(comint-backward-matching-input regexp arg)</code> <br> <a name="index-comint_002dbackward_002dmatching_002dinput-61"></a><code>(comint-forward-matching-input regexp arg)</code> <br> <a name="index-comint_002dforward_002dmatching_002dinput-62"></a>Search backward (forward) through the transcript buffer for the <var>arg</var>'th previous (next) command matching <var>regexp</var>. <var>arg</var> is the prefix argument; <var>regexp</var> is prompted for in the minibuffer. </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Transcript-resubmit"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Saving-transcripts">Saving transcripts</a>, Previous: <a rel="previous" accesskey="p" href="#Process-buffer-motion">Process buffer motion</a>, Up: <a rel="up" accesskey="u" href="#Transcript">Transcript</a> </div> <h4 class="subsection">4.4.3 Re-submitting commands from the transcript</h4> <p>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 <em>output</em>, an error is signalled). Note all three commands involve the <RETURN> key. <ul> <li><kbd>RET</kbd> (<code>inferior-ess-send-input</code>) <br> <a name="index-inferior_002dess_002dsend_002dinput-63"></a>Copy the command under the cursor to the current command line, and execute it. <li><kbd>C-c RET</kbd> (<code>comint-copy-old-input</code>) <br> <a name="index-comint_002dcopy_002dold_002dinput-64"></a>Copy the command under the cursor to the current command line, but don't execute it. Leaves the cursor on the command line so that the copied command may be edited. <li><kbd>M-RET</kbd> (<code>ess-transcript-send-command-and-move</code>) <br> <a name="index-ess_002dtranscript_002dsend_002dcommand_002dand_002dmove-65"></a>Copy the command under the cursor to the current command line, and execute it. Moves the cursor to the following command. </ul> <p>When the cursor is not after the current prompt, the <RETURN> key has a slightly different behavior than usual. Pressing <kbd>RET</kbd> 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 <kbd>C-c RET</kbd> instead; it copies the command to the current prompt but does not execute it, allowing you to edit it before submitting it. <p>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 <kbd>M-RET</kbd> instead, which leaves the cursor at the command line following the one you re-submitted. Thus by using <kbd>M-RET</kbd> repeatedly, you can re-submit a whole series of commands. <p>These commands work even if if the current line is a continuation line (i.e. the prompt is ‘<samp><span class="samp">+</span></samp>’ instead of ‘<samp><span class="samp">></span></samp>’) — 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 <a name="index-multi_002dline-commands_002c-resubmitting-66"></a>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 <a href="#Command-History">Command History</a>. <!-- node-name, next, previous, up --> <div class="node"> <a name="Saving-transcripts"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#Transcript-resubmit">Transcript resubmit</a>, Up: <a rel="up" accesskey="u" href="#Transcript">Transcript</a> </div> <h4 class="subsection">4.4.4 Keeping a record of your S session</h4> <p>To keep a record of your S session in a disk file, use the Emacs command <kbd>C-x C-w</kbd> (<code>write-file</code>) 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 <kbd>C-x C-s</kbd>. You can make ESS prompt you for a filename in which to save the transcript every time you start S by setting the variable <a name="index-ess_002dask_002dabout_002dtransfile-67"></a><code>ess-ask-about-transfile</code> to <code>t</code>; see <a href="#Customizing-startup">Customizing startup</a>. <a name="index-transcript-file-names-68"></a>We recommend you save your transcripts with filenames that end in ‘<samp><span class="samp">.St</span></samp>’. There is a special mode (ESS transcript mode — see <a href="#Transcript-Mode">Transcript Mode</a>) for editing transcript files which is automatically selected for files with this suffix. <p><a name="index-editing-transcripts-69"></a>S transcripts can get very large, so some judicious editing is appropriate if you are saving it in a file. Use <kbd>C-c C-o</kbd> 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 <kbd>M-h C-w</kbd>. Also, remember that <kbd>C-c C-e</kbd> (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. <p>Finally, if you intend to produce S source code (suitable for using with <code>source()</code> or inclusion in an S function) from a transcript, then the command <kbd>M-x ess-transcript-clean-region</kbd> may be of use. <a name="index-ess_002dtranscript_002dclean_002dregion-70"></a>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! <!-- node-name, next, previous, up --> <div class="node"> <a name="Command-History"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#History-expansion">History expansion</a>, Previous: <a rel="previous" accesskey="p" href="#Transcript">Transcript</a>, Up: <a rel="up" accesskey="u" href="#Entering-commands">Entering commands</a> </div> <h3 class="section">4.5 Command History</h3> <p><a name="index-command-history-71"></a><a name="index-editing-commands-72"></a><a name="index-re_002dexecuting-commands-73"></a> 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 <code>comint-input-ring-size</code> in <a name="index-comint_002dinput_002dring_002dsize-74"></a><code>inferior-ess-mode-hook</code>.) The simplest history commands simply select the next and previous commands in the input history: <ul> <li><kbd>M-p</kbd> (<code>comint-previous-input</code>) <br> <a name="index-comint_002dprevious_002dinput-75"></a>Select the previous command in the input history. <li><kbd>M-n</kbd> (<code>comint-next-input</code>) <br> <a name="index-comint_002dnext_002dinput-76"></a>Select the next command in the input history. </ul> <p class="noindent">For example, pressing <kbd>M-p</kbd> 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 <kbd>RET</kbd> to send the edited command to the ESS process. <p>If you want to select a particular command from the history by matching it against a regular expression (see <a href="emacs.html#Regexps">Syntax of Regular Expression</a>), to search for a particular variable name for example, these commands are also available: <ul> <li><kbd>M-r</kbd> (<code>comint-previous-matching-input</code>) <br> <a name="index-comint_002dprevious_002dmatching_002dinput-77"></a>Prompt for a regular expression, and search backwards through the input history for a command matching the expression. <li><kbd>M-s</kbd> (<code>comint-next-matching-input</code>) <br> <a name="index-comint_002dnext_002dmatching_002dinput-78"></a>Prompt for a regular expression, and search backwards through the input history for a command matching the expression. </ul> <p class="noindent">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: <ul> <li><kbd>A-M-r</kbd> (<code>comint-previous-matching-input-from-input</code>) <br> <a name="index-comint_002dprevious_002dmatching_002dinput_002dfrom_002dinput-79"></a>Select the previous command in the history which matches the string typed so far. <li><kbd>A-M-s</kbd> (<code>comint-next-matching-input-from-input</code>) <br> <a name="index-comint_002dnext_002dmatching_002dinput_002dfrom_002dinput-80"></a>Select the next command in the history which matches the string typed so far. </ul> <p class="noindent">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 <code>attach()</code> command, you may only need to type <kbd>att</kbd> and then <kbd>A-M-r</kbd> and <kbd>RET</kbd>. (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.) <p>See <a href="emacs.html#Shell-Ring">Shell History Ring</a>, for a more detailed discussion of the history mechanism. <!-- node-name, next, previous, up --> <div class="node"> <a name="History-expansion"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Hot-keys">Hot keys</a>, Previous: <a rel="previous" accesskey="p" href="#Command-History">Command History</a>, Up: <a rel="up" accesskey="u" href="#Entering-commands">Entering commands</a> </div> <h3 class="section">4.6 References to historical commands</h3> <p>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 <code>csh</code>. History references are introduced by a ‘<samp><span class="samp">!</span></samp>’ or ‘<samp><span class="samp">^</span></samp>’ character and have meanings as follows: <dl> <dt>‘<samp><span class="samp">!!</span></samp>’<dd>The immediately previous command <br><dt>‘<samp><span class="samp">!-</span><var>N</var></samp>’<dd>The <var>N</var>th previous command <br><dt>‘<samp><span class="samp">!text</span></samp>’<dd>The last command beginning with the string ‘<samp><span class="samp">text</span></samp>’ <br><dt>‘<samp><span class="samp">!?text</span></samp>’<dd>The last command containing the string ‘<samp><span class="samp">text</span></samp>’ </dl> <p>In addition, you may follow the reference with a <dfn>word designator</dfn> to select particular <dfn>words</dfn> 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 <code>comint-delimiter-argument-list</code> to a list of characters that are allowed to separate words and <a name="index-comint_002ddelimiter_002dargument_002dlist-81"></a>themselves form words.) Words are numbered beginning with zero. The word designator usually begins with a ‘<samp><span class="samp">:</span></samp>’ (colon) character; however it may be omitted if the word reference begins with a ‘<samp><span class="samp">^</span></samp>’, ‘<samp><span class="samp">$</span></samp>’, ‘<samp><span class="samp">*</span></samp>’ or ‘<samp><span class="samp">-</span></samp>’. If the word is to be selected from the previous command, the second ‘<samp><span class="samp">!</span></samp>’ character can be omitted from the event specification. For instance, ‘<samp><span class="samp">!!:1</span></samp>’ and ‘<samp><span class="samp">!:1</span></samp>’ both refer to the first word of the previous command, while ‘<samp><span class="samp">!!$</span></samp>’ and ‘<samp><span class="samp">!$</span></samp>’ both refer to the last word in the previous command. The format of word designators is as follows: <dl> <dt>‘<samp><span class="samp">0</span></samp>’<dd>The zeroth word (i.e. the first one on the command line) <br><dt>‘<samp><var>n</var></samp>’<dd>The <var>n</var>th word, where <var>n</var> is a number <br><dt>‘<samp><span class="samp">^</span></samp>’<dd>The first word (i.e. the second one on the command line) <br><dt>‘<samp><span class="samp">$</span></samp>’<dd>The last word <br><dt>‘<samp><var>x</var><span class="samp">-</span><var>y</var></samp>’<dd>A range of words; ‘<samp><span class="samp">-</span><var>y</var></samp>’ abbreviates ‘<samp><span class="samp">0-</span><var>y</var></samp>’ <br><dt>‘<samp><span class="samp">*</span></samp>’<dd>All the words except the zeroth word, or nothing if the command had just one word (the zeroth) <br><dt>‘<samp><var>x</var><span class="samp">*</span></samp>’<dd>Abbreviates <var>x</var>-$ <br><dt>‘<samp><var>x</var><span class="samp">-</span></samp>’<dd>Like ‘<samp><var>x</var><span class="samp">*</span></samp>’, but omitting the last word </dl> <p>In addition, you may surround the entire reference except for the first ‘<samp><span class="samp">!</span></samp>’ by braces to allow it to be followed by other (non-whitespace) characters (which will be appended to the expanded reference). <p>Finally, ESS also provides quick substitution; a reference like ‘<samp><span class="samp">^old^new^</span></samp>’ means “the last command, but with the first occurrence of the string ‘<samp><span class="samp">old</span></samp>’ replaced with the string ‘<samp><span class="samp">new</span></samp>’” (the last ‘<samp><span class="samp">^</span></samp>’ is optional). Similarly, ‘<samp><span class="samp">^old^</span></samp>’ means “the last command, with the first occurrence of the string ‘<samp><span class="samp">old</span></samp>’ deleted” (again, the last ‘<samp><span class="samp">^</span></samp>’ is optional). <p>To convert a history reference as described above to an input suitable for S, you need to <dfn>expand</dfn> 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 <kbd>SPC TAB</kbd>. This will convert the history reference into an S command from the history, which you can then edit or press <RET> to execute. <p>For example, to execute the last command that referenced the variable <code>data</code>, type <kbd>!?data SPC TAB RET</kbd>. <!-- node-name, next, previous, up --> <div class="node"> <a name="Hot-keys"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Statistical-Process-running-in-ESS_003f">Statistical Process running in ESS?</a>, Previous: <a rel="previous" accesskey="p" href="#History-expansion">History expansion</a>, Up: <a rel="up" accesskey="u" href="#Entering-commands">Entering commands</a> </div> <h3 class="section">4.7 Hot keys for common commands</h3> <p>ESS provides a number of commands for executing the commonly used functions. These commands below are basically information-gaining commands (such as <code>objects()</code> or <code>search()</code>) 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 <code>ess-execute-in-process-buffer</code> which, if <a name="index-ess_002dexecute_002din_002dprocess_002dbuffer-82"></a>non-<code>nil</code>, means that these commands will produce their output in the process buffer instead. In any case, passing a prefix argument to the commands (with <kbd>C-u</kbd>) will reverse the meaning of <code>ess-execute-in-process-buffer</code> 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: <ul> <li><kbd>C-c C-x</kbd> (<code>ess-execute-objects</code>) <br> <a name="index-ess_002dexecute_002dobjects-83"></a>Sends the <code>objects()</code> <a name="index-objects_0028_0029-84"></a>command to the ESS process. A prefix argument specifies the position on the search list (use a negative argument to toggle <code>ess-execute-in-process-buffer</code> as well). A quick way to see what objects are in your working directory. <a name="index-objects-85"></a><a name="index-objects_0028_0029-86"></a> <li><kbd>C-c C-s</kbd> (<code>ess-execute-search</code>) <br> <a name="index-ess_002dexecute_002dsearch-87"></a>Sends the <code>search()</code> <a name="index-search_0028_0029-88"></a>command to the ESS process. <a name="index-search-list-89"></a><a name="index-search_0028_0029-90"></a> <li><kbd>C-c C-e</kbd> (<code>ess-execute</code>) <br> <a name="index-ess_002dexecute-91"></a>Prompt for an ESS expression, and evaluate it. </ul> <p><code>ess-execute</code> 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 <a href="emacs.html#Keyboard-Macros">Keyboard Macros</a>. <a name="index-hot-keys-92"></a><a name="index-keyboard-short-cuts-93"></a> The following hot keys do not use <code>ess-execute-in-process-buffer</code> to decide where to display the output — they either always display in the process buffer or in a separate buffer, as indicated: <ul> <li><kbd>C-c C-a</kbd> (<code>ess-execute-attach</code>) <br> <a name="index-ess_002dexecute_002dattach-94"></a>Prompts for a directory to attach to the ESS process with the <code>attach()</code> command. <a name="index-attach_0028_0029-95"></a>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 <code>attach()</code> command actually executed appears in the process buffer. <li><kbd>C-c C-l</kbd> (<code>ess-load-file</code>) <br> <a name="index-ess_002dload_002dfile-96"></a>Prompts for a file to load into the ESS process using <code>source()</code>. If there is an error during loading, you can jump to the error in the file with <kbd>C-x `</kbd> (<code>ess-parse-errors</code>). <a name="index-ess_002dparse_002derrors-97"></a>See <a href="#Error-Checking">Error Checking</a>, for more details. <li><kbd>C-c C-v</kbd> (<code>ess-display-help-on-object</code>) <br> Pops up a help buffer for an S object or function. See <a href="#Help">Help</a> for more details. <li><kbd>C-c C-q</kbd> (<code>ess-quit</code>) <br> <a name="index-quitting-from-ESS-98"></a><a name="index-killing-the-ESS-process-99"></a>Sends the <code>q()</code> <a name="index-q_0028_0029-100"></a>command to the ESS process (or <code>(exit)</code> <a name="index-exit_0028_0029-101"></a>to the <b>XLS</b> 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 <code>q()</code> yourself, otherwise you will need to issue the command <kbd>M-x ess-cleanup</kbd> <a name="index-ess_002dcleanup-102"></a><a name="index-cleaning-up-103"></a><a name="index-temporary-buffers_002c-killing-104"></a><a name="index-killing-temporary-buffers-105"></a>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. </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Statistical-Process-running-in-ESS%3f"></a> <a name="Statistical-Process-running-in-ESS_003f"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Emacsclient">Emacsclient</a>, Previous: <a rel="previous" accesskey="p" href="#Hot-keys">Hot keys</a>, Up: <a rel="up" accesskey="u" href="#Entering-commands">Entering commands</a> </div> <h3 class="section">4.8 Is the Statistical Process running under ESS?</h3> <p><a name="index-STERM-106"></a><a name="index-STERM-107"></a>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. <p>ESS sets <code>options(STERM="iESS")</code> for S language processes running in an inferior <code>i<acronym>ESS[S]</acronym><!-- /@w --></code> or <code>i<acronym title="[S]">ESS[R]</acronym><!-- /@w --></code> buffer. <p>ESS sets <code>options(STERM="ddeESS")</code> 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 <code>ddeESS[S]</code> buffer. <p>Other values of <code>options()$STERM</code> that we recommend are: <ul> <li><code>length</code>: Fixed length xterm or telnet window. <li><code>scrollable</code>: Unlimited length xterm or telnet window. <li><code>server</code>: S-Plus Stat Server. <li><code>BATCH</code>: BATCH. <li><code>Rgui</code>: R GUI. <li><code>Commands</code>: S-Plus GUI without DDE interface to ESS. </ul> <p>Additional values may be recommended in the future as new interaction protocols are created. Unlike the values <code>iESS</code> and <code>ddeESS</code>, ESS can't set these other values since the S language program is not under the control of ESS. <!-- node-name, next, previous, up --> <div class="node"> <a name="Emacsclient"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Other">Other</a>, Previous: <a rel="previous" accesskey="p" href="#Statistical-Process-running-in-ESS_003f">Statistical Process running in ESS?</a>, Up: <a rel="up" accesskey="u" href="#Entering-commands">Entering commands</a> </div> <h3 class="section">4.9 Using emacsclient</h3> <p><a name="index-emacsclient-108"></a> When starting R or S under Unix, ESS sets <code>options(editor="emacsclient")</code>. (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 <code>iterator</code>, typing <code>fix(iterator)</code>, 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 <code>edit()</code> rather than <code>fix()</code> means that the function is not updated. Finally, the S function <code>page(x)</code> will also show a text representation of the object <code>x</code> in a temporary Emacs buffer. <!-- node-name, next, previous, up --> <div class="node"> <a name="Other"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#Emacsclient">Emacsclient</a>, Up: <a rel="up" accesskey="u" href="#Entering-commands">Entering commands</a> </div> <h3 class="section">4.10 Other commands provided by inferior-ESS</h3> <p>The following commands are also provided in the process buffer: <ul> <li><kbd>C-c C-c</kbd> (<code>comint-interrupt-subjob</code>) <br> <a name="index-comint_002dinterrupt_002dsubjob-109"></a>Sends a Control-C signal to the ESS process. This has the effect of <a name="index-aborting-S-commands-110"></a><a name="index-interrupting-S-commands-111"></a>aborting the current command. <li><kbd>C-c C-z</kbd> (<code>ess-abort</code>) <br> <a name="index-ess_002dabort-112"></a><a name="index-comint_002dstop_002dsubjob-113"></a>Sends a STOP signal to the ESS process, killing it immediately. It's not a good idea to use this, in general: Neither <code>q()</code> nor <code>.Last</code> will be executed and device drivers will not finish cleanly. This command is provided as a safety to <code>comint-stop-subjob</code>, which is usually bound to <kbd>C-c C-z</kbd>. If you want to quit from S, use <kbd>C-c C-q</kbd> (<code>ess-quit</code>) instead. <a name="index-ess_002dquit-114"></a><a name="index-aborting-the-ESS-process-115"></a> <li><kbd>C-c C-d</kbd> (<code>ess-dump-object-into-edit-buffer</code>) <br> <a name="index-ess_002ddump_002dobject_002dinto_002dedit_002dbuffer-116"></a>Prompts for an object to be edited in an edit buffer. See <a href="#Editing">Editing</a>. </ul> <p>Other commands available in Inferior S mode are discussed in <a href="emacs.html#Shell-Mode">Shell Mode</a>. <!-- node-name, next, previous, up --> <div class="node"> <a name="Transcript-Mode"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS-for-the-S-family">ESS for the S family</a>, Previous: <a rel="previous" accesskey="p" href="#Entering-commands">Entering commands</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">5 Manipulating saved transcript files</h2> <p>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 <dfn>transcript file</dfn>, which should normally have the suffix <samp><span class="file">.St</span></samp>. 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. <p>If you load file a with the suffix <samp><span class="file">.St</span></samp> into Emacs, it is placed in S Transcript Mode. Transcript Mode is similar to Inferior S mode (see <a href="#Entering-commands">Entering commands</a>): <a name="index-transcript-mode-motion-117"></a><a name="index-motion-in-transcript-mode-118"></a>paragraphs are defined as a command and its output, and you can move though commands either with the paragraph commands or with <kbd>C-c C-p</kbd> and <kbd>C-c C-n</kbd>. <ul class="menu"> <li><a accesskey="1" href="#Resubmit">Resubmit</a>: Resubmitting commands from the transcript file <li><a accesskey="2" href="#Clean">Clean</a>: Cleaning transcript files </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Resubmit"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Clean">Clean</a>, Previous: <a rel="previous" accesskey="p" href="#Transcript-Mode">Transcript Mode</a>, Up: <a rel="up" accesskey="u" href="#Transcript-Mode">Transcript Mode</a> </div> <h3 class="section">5.1 Resubmitting commands from the transcript file</h3> <p>Three commands are provided to re-submit command lines from the transcript file to a running ESS process. They are: <ul> <li><kbd>RET</kbd> (<code>ess-transcript-send-command</code>) <br> Send the current command line to the ESS process, and execute it. <a name="index-ess_002dtranscript_002dsend_002dcommand-119"></a> <li><kbd>C-c RET</kbd> (<code>ess-transcript-copy-command</code>) <br> Copy the current command to the ESS process, and switch to the ESS process buffer (ready to edit the copied command). <a name="index-ess_002dtranscript_002dcopy_002dcommand-120"></a> <li><kbd>M-RET</kbd> (<code>ess-transcript-send-command-and-move</code>) <br> Send the current command to the ESS process, and move to the next command line. This command is useful for submitting a series of commands. </ul> <p class="noindent">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. <!-- node-name, next, previous, up --> <div class="node"> <a name="Clean"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#Resubmit">Resubmit</a>, Up: <a rel="up" accesskey="u" href="#Transcript-Mode">Transcript Mode</a> </div> <h3 class="section">5.2 Cleaning transcript files</h3> <p>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: <ul> <li><kbd>C-c C-w</kbd> (<code>ess-transcript-clean-region</code>) <br> Deletes all prompts and command output in the region, leaving only the commands themselves. </ul> <p class="noindent">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 <a href="#Evaluating-code">Evaluating code</a>) using the code evaluation commands from S mode, also available in S Transcript Mode. <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS-for-the-S-family"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Editing">Editing</a>, Previous: <a rel="previous" accesskey="p" href="#Transcript-Mode">Transcript Mode</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">6 ESS for the S family</h2> <ul class="menu"> <li><a accesskey="1" href="#ESS_0028S_0029_002d_002dEditing-files">ESS(S)--Editing files</a> <li><a accesskey="2" href="#iESS_0028S_0029_002d_002dInferior-ESS-processes">iESS(S)--Inferior ESS processes</a> <li><a accesskey="3" href="#ESS_002dhelp_002d_002dassistance-with-viewing-help">ESS-help--assistance with viewing help</a> <li><a accesskey="4" href="#Philosophies-for-using-ESS_0028S_0029">Philosophies for using ESS(S)</a> <li><a accesskey="5" href="#Scenarios-for-use-_0028possibilities_002d_002dbased-on-actual-usage_0029">Scenarios for use (possibilities--based on actual usage)</a> <li><a accesskey="6" href="#Customization-Examples-and-Solutions-to-Problems">Customization Examples and Solutions to Problems</a> </ul> <div class="node"> <a name="ESS(S)--Editing-files"></a> <a name="ESS_0028S_0029_002d_002dEditing-files"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#iESS_0028S_0029_002d_002dInferior-ESS-processes">iESS(S)--Inferior ESS processes</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-the-S-family">ESS for the S family</a> </div> <!-- node-name, next, previous, up - don't use @ESS .. --> <h3 class="section">6.1 ESS[S]–Editing files</h3> <p><acronym>ESS[S]</acronym> is the mode for editing S language files. This mode handles: <ul> <li> proper indenting, generated by both [Tab] and [Return]. <li> color and font choices based on syntax. <li> ability to send the contents of an entire buffer, a highlighted region, an S function, or a single line to an inferior S process, if one is currently running. <li> ability to switch between processes which would be the target of the buffer (for the above). <li> The ability to request help from an S process for variables and functions, and to have the results sent into a separate buffer. <li> completion of object names and file names. </ul> <p><acronym>ESS[S]</acronym> mode should be automatically turned on when loading a file with the suffices found in ess-site (*.R, *.S, *.s, etc). Alternatively, type <kbd>M-x R-mode</kbd> to put the current buffer into R mode. However, one will have to start up an inferior process to take advantage of the interactive features. <div class="node"> <a name="iESS(S)--Inferior-ESS-processes"></a> <a name="iESS_0028S_0029_002d_002dInferior-ESS-processes"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS_002dhelp_002d_002dassistance-with-viewing-help">ESS-help--assistance with viewing help</a>, Previous: <a rel="previous" accesskey="p" href="#ESS_0028S_0029_002d_002dEditing-files">ESS(S)--Editing files</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-the-S-family">ESS for the S family</a> </div> <!-- node-name, next, previous, up --> <h3 class="section">6.2 iESS[S]–Inferior ESS processes</h3> <p>iESS (inferior ESS) is the mode for interfacing with active statistical processes (programs). This mode handles: <ul> <li> proper indenting, generated by both [Tab] and [Return]. <li> color and font highlighting based on syntax. <li> ability to resubmit the contents of a multi-line command to the executing process with a single keystroke [RET]. <li> The ability to request help from the current process for variables and functions, and to have the results sent into a separate buffer. <li> completion of object names and file names. <li> interactive history mechanism. <li> transcript recording and editing. </ul> <p>To start up iESS mode, use: <pre class="example"> M-x S+3 M-x S4 M-x S+5 M-x S+6 M-x R </pre> <p>(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: <p>M-x S <p><a name="index-command-line-arguments-121"></a>In the (rare) case that you wish to pass command line arguments to the starting S+6 process, set the variable <code>inferior-Splus-args</code>. <p>Note that R has some extremely useful command line arguments. For example, <code>--vanilla</code> will ensure R starts up without loading in any init files. To enter a command line argument, call R using a "prefix argument", by <p>C-u M-x R <p>and when ESS prompts for "Starting Args ? ", enter (for example): <p><code>--vanilla</code> <p>Then that R process will be started up using <code>R --vanilla</code>. If you wish to always call R with certain arguments, set the variable <code>inferior-R-args</code> accordingly. <!-- Menubar access to other versions of R and Sqpe --> <p>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 <code>exec-path</code> for R binaries. If ESS cannot find your R binaries, on Unix you can change the unix environment variable <code>PATH</code>, as this variable is used to set <code>exec-path</code>. <p>R on Unix systems: If you have "R-1.8.1" on your <code>exec-path</code>, it can be started using <kbd>M-x R-1.8.1</kbd>. 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 <code>ess-r-versions</code>. To see which functions have been created for starting different versions of R, type <kbd>M-x R-</kbd> and then hit [Tab]. These other versions of R can also be started from the "ESS->Start Process->Other" menu. <p>R on Windows systems: If you have "rw1081" on your <code>exec-path</code>, it can be started using <kbd>M-x rw1081</kbd>. By default, ESS will find versions of R located in directories parallel to the version of R in your <code>PATH</code>. If your versions of R are called other names, you will need to change the variable <code>ess-rterm-versions</code>. To see which functions have been created for starting different versions of R, type <kbd>M-x rw</kbd> and then hit [Tab]. These other versions of R can also be started from the "ESS->Start Process->Other" menu. <p>Once ESS has found these extra versions of R, it will then create a new function, called <kbd>M-x R-newest</kbd>, which will call the newest version of R that it found. (ESS examines the date in the first line of information from <code>R --version</code> to determine which is newest.) <p>S on Unix systems: If you have "Splus7" on your <code>exec-path</code>, it can be started using <kbd>M-x Splus7</kbd>. 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 <code>ess-s-versions</code>. To see which functions have been created for starting different versions of Splus, type <kbd>M-x Splus</kbd> and then hit [Tab]. These other versions of Splus can also be started from the "ESS->Start Process->Other" menu. <p>A second mechanim is also available for running other versions of Splus. The variable <code>ess-s-versions-list</code> 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: <pre class="example"> (setq ess-s-versions-list '( ("Splus64" "/usr/local/bin/Splus64") ("Splus64-j" "/usr/local/bin/Splus64" "-j"))) </pre> <p>which will then allow you to do <kbd>M-x Splus64-j</kbd> to start Splus64 with the corresponding command line arguments. <p>If you change the value of either <code>ess-s-versions</code> or <code>ess-s-versions-list</code>, you should put them in your .emacs before ess-site is loaded, since the new emacs functions are created when ESS is loaded. <p>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 <kbd>M-x splus61</kbd>. 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 <code>ess-SHOME-versions</code>. To see which functions have been created for starting different versions of S-Plus, type <kbd>M-x spl</kbd> and then hit [Tab]. These other versions of S-Plus can also be started from the "ESS->Start Process->Other" menu. <div class="node"> <a name="ESS-help--assistance-with-viewing-help"></a> <a name="ESS_002dhelp_002d_002dassistance-with-viewing-help"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Philosophies-for-using-ESS_0028S_0029">Philosophies for using ESS(S)</a>, Previous: <a rel="previous" accesskey="p" href="#iESS_0028S_0029_002d_002dInferior-ESS-processes">iESS(S)--Inferior ESS processes</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-the-S-family">ESS for the S family</a> </div> <!-- node-name, next, previous, up --> <h3 class="section">6.3 ESS-help–assistance with viewing help</h3> <p>ESS has built-in facilities for viewing help files from S. See <a href="#Help">Help</a>. <div class="node"> <a name="Philosophies-for-using-ESS(S)"></a> <a name="Philosophies-for-using-ESS_0028S_0029"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Scenarios-for-use-_0028possibilities_002d_002dbased-on-actual-usage_0029">Scenarios for use (possibilities--based on actual usage)</a>, Previous: <a rel="previous" accesskey="p" href="#ESS_002dhelp_002d_002dassistance-with-viewing-help">ESS-help--assistance with viewing help</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-the-S-family">ESS for the S family</a> </div> <h3 class="section">6.4 Philosophies for using ESS[S]</h3> <p>The first is preferred, and configured for. The second one can be retrieved again, by changing emacs variables. <p>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. <p>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: <pre class="example"> (setq ess-keep-dump-files 'nil) (setq ess-delete-dump-files t) (setq ess-mode-silently-save nil) </pre> <p>The second saves a small amount of disk space. The first allows for better portability as well as external version control for code. <div class="node"> <a name="Scenarios-for-use-(possibilities--based-on-actual-usage)"></a> <a name="Scenarios-for-use-_0028possibilities_002d_002dbased-on-actual-usage_0029"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Customization-Examples-and-Solutions-to-Problems">Customization Examples and Solutions to Problems</a>, Previous: <a rel="previous" accesskey="p" href="#Philosophies-for-using-ESS_0028S_0029">Philosophies for using ESS(S)</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-the-S-family">ESS for the S family</a> </div> <h3 class="section">6.5 Scenarios for use (possibilities–based on actual usage)</h3> <p>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 "##"). <pre class="display"> 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") </pre> <div class="node"> <a name="Customization-Examples-and-Solutions-to-Problems"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#Scenarios-for-use-_0028possibilities_002d_002dbased-on-actual-usage_0029">Scenarios for use (possibilities--based on actual usage)</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-the-S-family">ESS for the S family</a> </div> <h3 class="section">6.6 Customization Examples and Solutions to Problems</h3> <p>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 ess-sp3-d.el and ess-s4-d.el files to be "S" instead of "S4" and "S+3". This will ensure that all the inferior process buffer names are "*S*". <p>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 add after your (require 'ess-site) or (load "ess-site") command in your .emacs file, the line: <pre class="example"> (setq ess-plain-first-buffername nil) </pre> <p>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. <p>Solution: add a " at the end of the "Dumped..." statement, to revert the font-lock face back to normal. <p>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. <p>Solution: Use <kbd>M-x ess-change-directory</kbd>. This will prompt you for the directory to change to. It will then change directory within the *S* buffer, and also update the emacs variable <code>default-directory</code>. Alternatively, if you have already executed setwd(), press <kbd>M-RET</kbd> within the *S* buffer so that Emacs can update <code>default-directory</code>. <!-- node-name, next, previous, up --> <div class="node"> <a name="Editing"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Editing-R-documentation">Editing R documentation</a>, Previous: <a rel="previous" accesskey="p" href="#ESS-for-the-S-family">ESS for the S family</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">7 Editing S functions</h2> <p><a name="index-editing-functions-122"></a>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. <ul class="menu"> <li><a accesskey="1" href="#Edit-buffer">Edit buffer</a>: Edit objects in a specialized buffer <li><a accesskey="2" href="#Loading">Loading</a>: Loading source files into the ESS process <li><a accesskey="3" href="#Error-Checking">Error Checking</a>: Detecting errors in source files <li><a accesskey="4" href="#Evaluating-code">Evaluating code</a>: Sending code to the ESS process <li><a accesskey="5" href="#Indenting">Indenting</a>: Indenting and formatting S code <li><a accesskey="6" href="#Other-edit-buffer-commands">Other edit buffer commands</a>: Commands for motion, completion and more <li><a accesskey="7" href="#Source-Files">Source Files</a>: Maintaining S source files <li><a accesskey="8" href="#Source-Directories">Source Directories</a>: Names and locations of dump files </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Edit-buffer"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Loading">Loading</a>, Previous: <a rel="previous" accesskey="p" href="#Editing">Editing</a>, Up: <a rel="up" accesskey="u" href="#Editing">Editing</a> </div> <h3 class="section">7.1 Creating or modifying S objects</h3> <p><a name="index-edit-buffer-123"></a> To edit an S object, type <ul> <li><kbd>C-c C-d</kbd> (<code>ess-dump-object-into-edit-buffer</code>) <br> <a name="index-ess_002ddump_002dobject_002dinto_002dedit_002dbuffer-124"></a>Edit an S object in its own edit buffer. </ul> <p>from within the ESS process buffer (<code>*S*</code>). 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 <kbd>TAB</kbd> key), <a name="index-completion_002c-when-prompted-for-object-names-125"></a>or you may enter the name of a new object. <a name="index-creating-new-objects-126"></a><a name="index-new-objects_002c-creating-127"></a>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 <code>ess-function-template</code> <a name="index-ess_002dfunction_002dtemplate-128"></a>is non-<code>nil</code>, you will be presented with a template defined by that variable, which defaults to a skeleton function construct. <p>You may then edit the function as required. The edit buffer generated by <code>ess-dump-object-into-edit-buffer</code> is placed in the <code>ESS</code> 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. <p><a name="index-dump-files-129"></a><a name="index-reverting-function-definitions-130"></a>Note: when you dump a file with <kbd>C-c C-d</kbd>, 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 <a href="#Source-Files">Source Files</a>) 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 <code>dump()</code> command issued. <a name="index-dump_0028_0029-131"></a>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 <code>ess-dump-object-into-edit-buffer</code> by typing <kbd>C-u C-c C-d</kbd>. <!-- node-name, next, previous, up --> <div class="node"> <a name="Loading"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Error-Checking">Error Checking</a>, Previous: <a rel="previous" accesskey="p" href="#Edit-buffer">Edit buffer</a>, Up: <a rel="up" accesskey="u" href="#Editing">Editing</a> </div> <h3 class="section">7.2 Loading source files into the ESS process</h3> <p>The best way to get information — particularly function definitions — into S is to load them in as source file, using S's <code>source</code> function. You have already seen how to create source files using <kbd>C-c C-d</kbd>; ESS provides a complementary command for loading source files (even files not created with ESS!) into the ESS process: <ul> <li><kbd>C-c C-l</kbd> (<code>ess-load-file</code>) <br> <a name="index-ess_002dload_002dfile-132"></a>Loads a file into the ESS process using <code>source()</code>. <a name="index-source_0028_0029-133"></a></ul> <p class="noindent">After typing <kbd>C-c C-l</kbd> 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 <kbd>RET</kbd> 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 <kbd>C-c C-d</kbd>). The file will then be loaded, and if it loads successfully you will be returned to the ESS process. <!-- node-name, next, previous, up --> <div class="node"> <a name="Error-Checking"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Evaluating-code">Evaluating code</a>, Previous: <a rel="previous" accesskey="p" href="#Loading">Loading</a>, Up: <a rel="up" accesskey="u" href="#Editing">Editing</a> </div> <h3 class="section">7.3 Detecting errors in source files</h3> <p><a name="index-errors-134"></a><a name="index-parsing-errors-135"></a>If any errors occur when loading a file with <code>C-c C-l</code>, 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 <kbd>C-c `</kbd> (<code>ess-parse-errors</code>). <a name="index-ess_002dparse_002derrors-136"></a>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. <p>Sometimes the error is not caused by a syntax error (loading a non-existent file for example). In this case typing <kbd>C-c `</kbd> will simply display a buffer containing S's error message. You can force this behavior (and avoid jumping to the file when there <em>is</em> a syntax error) by passing a prefix argument to <code>ess-parse-errors</code> with <kbd>C-u C-c `</kbd>. <!-- node-name, next, previous, up --> <div class="node"> <a name="Evaluating-code"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Indenting">Indenting</a>, Previous: <a rel="previous" accesskey="p" href="#Error-Checking">Error Checking</a>, Up: <a rel="up" accesskey="u" href="#Editing">Editing</a> </div> <h3 class="section">7.4 Sending code to the ESS process</h3> <p>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 <code>source()</code> 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 <code>ess-eval-visibly-p</code> whose default is <code>nil</code> <a name="index-ess_002deval_002dvisibly_002dp-137"></a>(display output only). Passing a prefix argument (<kbd>C-u</kbd>) to any of the following commands, however, reverses the meaning of <code>ess-eval-visibly-p</code> for that command only — for example <kbd>C-u C-c C-j</kbd> 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 <code>source()</code> function <a name="index-source_0028_0029-138"></a><a name="index-echoing-commands-when-evaluating-139"></a><a name="index-evaluating-code-with-echoed-commands-140"></a>when you want the input as well as the output to be displayed. (You can sort of do this with <code>source()</code> when the option <code>echo=T</code> is set, except that prompts do not get displayed. ESS puts prompts in the right places.) The commands for evaluating code are: <a name="index-evaluating-S-expressions-141"></a> <ul><li><kbd>C-c C-j</kbd> (<code>ess-eval-line</code>) <br> <a name="index-ess_002deval_002dline-142"></a>Send the line containing point to the ESS process. <li><kbd>C-c M-j</kbd> (<code>ess-eval-line-and-go</code>) <br> <a name="index-ess_002deval_002dline_002dand_002dgo-143"></a>As above, but returns you to the ESS process buffer as well. <li><kbd>C-c C-f</kbd> or <kbd>ESC C-x</kbd> (aka <kbd>M-C-x</kbd>) (<code>ess-eval-function</code>) <br> <a name="index-ess_002deval_002dfunction-144"></a>Send the S function containing point to the ESS process. <li><kbd>C-c M-f</kbd> (<code>ess-eval-function-and-go</code>) <br> <a name="index-ess_002deval_002dfunction_002dand_002dgo-145"></a>As above, but returns you to the ESS process buffer as well. <li><kbd>C-c C-r</kbd> (<code>ess-eval-region</code>) <br> <a name="index-ess_002deval_002dregion-146"></a>Send the text between point and mark to the ESS process. <li><kbd>C-c M-r</kbd> (<code>ess-eval-region-and-go</code>) <br> <a name="index-ess_002deval_002dregion_002dand_002dgo-147"></a>As above, but returns you to the ESS process buffer as well. <li><kbd>C-c C-b</kbd> (<code>ess-eval-buffer</code>) <br> <a name="index-ess_002deval_002dbuffer-148"></a>Send the contents of the edit buffer to the ESS process. <li><kbd>C-c M-b</kbd> (<code>ess-eval-buffer-and-go</code>) <br> <a name="index-ess_002deval_002dfunction_002dand_002dgo-149"></a>As above, but returns you to the ESS process buffer as well. <li><kbd>C-c C-n</kbd> (<code>ess-eval-line-and-step</code>) <br> <a name="index-ess_002deval_002dline_002dand_002dstep-150"></a><a name="index-stepping-through-code-151"></a><a name="index-debugging-S-functions-152"></a>Sends the current line to the ESS process, echoing it in the process buffer, and moves point to the next line. Useful when debugging for stepping through your code. </ul> <p>It should be stressed once again that these <code>ess-eval-</code> 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, <kbd>C-c C-l</kbd> is the command to use to update the function's value. In particular, <code>ess-eval-buffer</code> is now largely obsolete. <p>One final command is provided for spot-evaluations of S code: <ul> <kbd>C-c C-t</kbd> (<code>ess-execute-in-tb</code>) <br> <a name="index-ess_002dexecute_002din_002dtb-153"></a>Prompt for an S expression and evaluate it. Displays result in a temporary buffer. </ul> <p class="noindent">This is useful for quick calculations, etc. <p>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 <code>comint-scroll-to-bottom-on-output</code> to <code>'others</code> or <code>t</code>. <!-- node-name, next, previous, up --> <div class="node"> <a name="Indenting"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Other-edit-buffer-commands">Other edit buffer commands</a>, Previous: <a rel="previous" accesskey="p" href="#Evaluating-code">Evaluating code</a>, Up: <a rel="up" accesskey="u" href="#Editing">Editing</a> </div> <h3 class="section">7.5 Indenting and formatting S code</h3> <p>ESS provides a sophisticated mechanism for indenting S source code (thanks to Ken'ichi Shibayama). Compound statements (delimited by ‘<samp><span class="samp">{</span></samp>’ and ‘<samp><span class="samp">}</span></samp>’) 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, <code>if</code> statements, calls to <code>expression()</code> 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. <p><a name="index-comments-in-S-154"></a>Comments are also handled specially by ESS, using an idea borrowed from the Emacs-Lisp indentation style. By default, comments beginning with ‘<samp><span class="samp">###</span></samp>’ are aligned to the beginning of the line. Comments beginning with ‘<samp><span class="samp">##</span></samp>’ are aligned to the current level of indentation for the block containing the comment. Finally, comments beginning with ‘<samp><span class="samp">#</span></samp>’ are aligned to a column on the right (the 40th column by default, but this value is controlled by the variable <code>comment-column</code>,) <a name="index-comment_002dcolumn-155"></a>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 <code>(setq ess-fancy-comments nil)</code> to your <samp><span class="file">.emacs</span></samp> file. <a name="index-ess_002dfancy_002dcomments-156"></a> ESS also supports Roxygen entries which is R documentation maintained in the source code as comments See <a href="#Roxygen">Roxygen</a>. <p>The indentation commands provided by ESS are: <a name="index-indenting-157"></a><a name="index-formatting-source-code-158"></a> <ul> <li><kbd>TAB</kbd> (<code>ess-indent-command</code>) <br> Indents the current line as S code. If a prefix argument is given, all following lines which are part of the same (compound) expression are indented by the same amount (but relative indents are preserved). <li><kbd>RET</kbd> (<code>newline-and-indent</code>) <br> <kbd>LFD</kbd> (<em>newline-and-indent</em>) <br> Insert a newline, and indent the next line. (Note that most keyboards nowadays do not have a <LINEFEED> key, but <kbd>C-j</kbd> is equivalent.) <li><kbd>ESC C-q</kbd> aka <kbd>M-C-q</kbd> aka <kbd>C-M-q</kbd> (<code>ess-indent-exp</code>) <br> Indents each line in the S (compound) expression which follows point. Very useful for beautifying your S code. <li><kbd>{</kbd> and <kbd>}</kbd> (<code>ess-electric-brace</code>) <br> The braces automatically indent to the correct position when typed. <li><kbd>M-;</kbd> (<code>indent-for-comment</code>) <br> Indents an existing comment line appropriately, or inserts an appropriate comment marker. <li><kbd>M-x ess-set-style</kbd> <br> Set the formatting style in this buffer to be one of the predefined styles, including <code>GNU</code>, <code>BSD</code>, <code>K&R</code>, <code>CLB</code>, and <code>C++</code>. The <code>DEFAULT</code> style uses the default values for the indenting variables; The <code>OWN</code> style allows you to use your own private values of the indentation variable, see below. </ul> <ul class="menu"> <li><a accesskey="1" href="#Styles">Styles</a>: Changing indentation styles </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Styles"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#Indenting">Indenting</a>, Up: <a rel="up" accesskey="u" href="#Indenting">Indenting</a> </div> <h4 class="subsection">7.5.1 Changing indentation styles</h4> <p>The combined value of nine variables that control indentation are collectively termed a <i>style</i>. ESS provides several styles covering the common styles of indentation: <code>DEFAULT</code>, <code>OWN</code>, <code>GNU</code>, <code>BSD</code>, <code>K&R</code>, <code>C++</code>, <code>RRR</code>, <code>CLB</code>. The variable <code>ess-style-alist</code> lists the value of each indentation variable per style. <p>If you wish to change from one predefined style to another, change the variable <code>ess-default-style</code>, for example: <pre class="example"> (setq ess-default-style 'C++) </pre> <p>The styles <code>DEFAULT</code> and <code>OWN</code> are initially identical. If you wish to edit some of the default values, set <code>ess-default-style</code> to <code>'OWN</code> and change <code>ess-own-style-list</code>. See <a href="#Customization">Customization</a>, for convenient ways to set both these variables. <p>If you prefer not to use the custom facility, you can change individual indentation variables within a hook, for example: <pre class="example"> (defun myindent-ess-hook () (setq ess-indent-level 4)) (add-hook 'ess-mode-hook 'myindent-ess-hook) </pre> <p>In the rare case that you'd like to add an entire new indentation style of your own, copy the definition of <code>ess-own-style-list</code> to a new variable and ensure that the last line of the <code>:set</code> declaration calls <code>ess-add-style</code> with a unique name for your style (e.g. <code>'MINE</code>). Finally, add <code>(setq ess-default-style 'MINE)</code> to use your new style. <!-- node-name, next, previous, up --> <div class="node"> <a name="Other-edit-buffer-commands"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Source-Files">Source Files</a>, Previous: <a rel="previous" accesskey="p" href="#Indenting">Indenting</a>, Up: <a rel="up" accesskey="u" href="#Editing">Editing</a> </div> <h3 class="section">7.6 Commands for motion, completion and more</h3> <p>A number of commands are provided to move across function definitions in the edit buffer: <ul> <li><kbd>ESC C-a</kbd> aka <kbd>C-M-a</kbd> (<code>ess-beginning-of-function</code>) <br> <a name="index-ess_002dbeginning_002dof_002dfunction-159"></a>Moves point to the beginning of the function containing point. <li><kbd>ESC C-e</kbd> aka <kbd>C-M-e</kbd> (<code>ess-end-of-function</code>) <br> <a name="index-ess_002dend_002dof_002dfunction-160"></a>Moves point to the end of the function containing point. <li><kbd>ESC C-h</kbd> aka <kbd>C-M-h</kbd> (<code>ess-mark-function</code>) <br> Places point at the beginning of the S function containing point, and mark at the end. </ul> Don't forget the usual Emacs commands for moving over balanced expressions and parentheses: See <a href="Emacs.html#Lists">Lists and Sexps</a>. <p><a name="index-completion-in-edit-buffer-161"></a>Completion is provided in the edit buffer in a similar fashion to the process buffer: <kbd>M-TAB</kbd> completes file names and <kbd>M-?</kbd> lists file completions. Since <TAB> is used for indentation in the edit buffer, object completion is now performed with <kbd>C-c TAB</kbd>. Note however that completion is only provided over globally known S objects (such as system functions) — it will <em>not</em> work for arguments to functions or other variables local to the function you are editing. <p>Finally, two commands are provided for returning to the ESS process buffer: <ul> <li><kbd>C-c C-z</kbd> (<code>ess-switch-to-end-of-ESS</code>) <br> <a name="index-ess_002dswitch_002dto_002dend_002dof_002dESS-162"></a>Returns you to the ESS process buffer, placing point at the end of the buffer. <li><kbd>C-c C-y</kbd> (<code>ess-switch-to-ESS</code>) <br> <a name="index-ess_002dswitch_002dto_002dESS-163"></a>Also returns to to the ESS process buffer, but leaves point where it was. </ul> <p>In addition some commands available in the process buffer are also available in the edit buffer. You can still read help files with <kbd>C-c C-v</kbd>, edit another function with <kbd>C-c C-d</kbd> and of course <kbd>C-c C-l</kbd> can be used to load a source file into S. See <a href="#Other">Other</a>, for more details on these commands. <!-- node-name, next, previous, up --> <div class="node"> <a name="Source-Files"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Source-Directories">Source Directories</a>, Previous: <a rel="previous" accesskey="p" href="#Other-edit-buffer-commands">Other edit buffer commands</a>, Up: <a rel="up" accesskey="u" href="#Editing">Editing</a> </div> <h3 class="section">7.7 Maintaining S source files</h3> <p>Every edit buffer in ESS is associated with a <dfn>dump file</dfn> on disk. Dump files are created whenever you type <kbd>C-c C-d</kbd> (<code>ess-dump-object-into-edit-buffer</code>), 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. <a name="index-dump-files-164"></a> <div class="defun"> — User Option: <b>ess-delete-dump-files</b><var><a name="index-ess_002ddelete_002ddump_002dfiles-165"></a></var><br> <blockquote><p>If non-<code>nil</code>, dump files created with C-c C-d are deleted immediately after they are created by the ess-process. </p></blockquote></div> <p>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 <em>don't</em> 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 <code>dump</code> function; it doesn't apply to source files which already exist. The default value is <code>t</code>. <div class="defun"> — User Option: <b>ess-keep-dump-files</b><var><a name="index-ess_002dkeep_002ddump_002dfiles-166"></a></var><br> <blockquote><p>Option controlling what to do with the dump file after an object has been successfully loaded into S. Valid values are <code>nil</code> (always delete), <code>ask</code> (always ask whether to delete), <code>check</code> (delete files generated with <kbd>C-c C-d</kbd> in this Emacs session, otherwise ask — this is the default) and <code>t</code> (never delete). This variable is buffer-local. </p></blockquote></div> <p>After an object has been successfully (i.e. without error) loaded back into S with <kbd>C-c C-l</kbd>, 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. <p><a name="index-comments-167"></a><a name="index-project-work-in-S-168"></a><a name="index-historic-backups-169"></a>If the value of <code>ess-keep-dump-files</code> is <code>t</code>, 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 <a href="emacs.html#Backup-Names">Single or Numbered Backups</a>, 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 <a href="emacs.html#Version-Control">Version Control</a>. As long as a dump file exists in the appropriate place for a particular object, editing that object with <kbd>C-c C-d</kbd> finds that file for editing (unless a prefix argument is given) — the ESS process is not consulted. Thus you can keep comments <em>outside</em> 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. <p>If the value of <code>ess-keep-dump-files</code> is nil, the dump file is always silently deleted after a successful load with <kbd>C-c C-l</kbd>. While this is useful for files that were created with <kbd>C-c C-d</kbd> 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 <code>ess-keep-dump-files</code> is buffer-local, you can make sure particular files are not deleted by setting it to <code>t</code> in the Local Variables section of the file See <a href="emacs.html#File-Variables">Local Variables in Files</a>. <p>A safer option is to set <code>ess-keep-dump-files</code> to <code>ask</code>; 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 <code>C-c C-d</code>, but not any other files, setting <code>ess-keep-dump-files</code> to <code>check</code> (the default value) will silently delete dump files created with <kbd>C-c C-d</kbd> 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. <p>Note that in all cases, if an error (such as a syntax error) is detected while loading the file with <kbd>C-c C-l</kbd>, the dump file is <em>never</em> 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. <p><a name="index-autosaving-170"></a>Dump buffers are always autosaved, regardless of the value of <code>ess-keep-dump-files</code>. <!-- node-name, next, previous, up --> <div class="node"> <a name="Source-Directories"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#Source-Files">Source Files</a>, Up: <a rel="up" accesskey="u" href="#Editing">Editing</a> </div> <h3 class="section">7.8 Names and locations of dump files</h3> <p><a name="index-dump-file-names-171"></a>Every dump file should be given a unique file name, usually the dumped object name with some additions. <div class="defun"> — User Option: <b>ess-dump-filename-template</b><var><a name="index-ess_002ddump_002dfilename_002dtemplate-172"></a></var><br> <blockquote><p>Template for filenames of dumped objects. <code>%s</code> is replaced by the object name. </p></blockquote></div> <p class="noindent">By default, dump file names are the user name, followed by ‘<samp><span class="samp">.</span></samp>’ and the object and ending with ‘<samp><span class="samp">.S</span></samp>’. Thus if user <code>joe</code> dumps the object <code>myfun</code> the dump file will have name <samp><span class="file">joe.myfun.S</span></samp>. The username part is included to avoid clashes when dumping into a publicly-writable directory, such as <samp><span class="file">/tmp</span></samp>; you may wish to remove this part if you are dumping into a directory owned by you. <p><a name="index-dump-file-directories-173"></a>You may also specify the directory in which dump files are written: <div class="defun"> — User Option: <b>ess-source-directory</b><var><a name="index-ess_002dsource_002ddirectory-174"></a></var><br> <blockquote><p>Directory name (ending in a slash) where S dump files are to be written. </p></blockquote></div> <p>By default, dump files are always written to <samp><span class="file">/tmp</span></samp>, which is fine when <code>ess-keep-dump-files</code> is <code>nil</code>. If you are keeping dump files, then you will probably want to keep them somewhere in your home directory, say <samp><span class="file">~/S-source</span></samp>. This could be achieved by including the following line in your <samp><span class="file">.emacs</span></samp> file: <a name="index-g_t_0040file_007b_002eemacs_007d-file-175"></a> <pre class="example"> (setq ess-source-directory (expand-file-name "~/S-source/")) </pre> <p>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 <code>ess-source-directory</code> 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 <samp><span class="file">Src</span></samp> of the directory the ESS process was run in. <pre class="example"> (setq ess-source-directory (lambda () (concat ess-directory "Src/"))) </pre> <p class="noindent"><a name="index-ess_002ddirectory-176"></a>(<code>ess-directory</code> 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: <a name="index-search-list-177"></a><a name="index-working-directory-178"></a> <pre class="example"> (setq ess-source-directory (lambda () (file-name-as-directory (expand-file-name (concat (car ess-search-list) "/.Src"))))) </pre> <p><a name="index-ess_002dsearch_002dlist-179"></a> 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. <div class="node"> <a name="Editing-R-documentation"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Help">Help</a>, Previous: <a rel="previous" accesskey="p" href="#Editing">Editing</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">8 Editing R documentation</h2> <p>ESS provides two ways of writing documentation for R objects. Either using the standard R documentation system or using in-source documentation written as structured comment fields for use with the Roxygen package. <ul class="menu"> <li><a accesskey="1" href="#R-documentation-files">R documentation files</a>: Edit objects in a specialized buffer <li><a accesskey="2" href="#Roxygen">Roxygen</a>: Loading source files into the ESS process </ul> <div class="node"> <a name="R-documentation-files"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Roxygen">Roxygen</a>, Previous: <a rel="previous" accesskey="p" href="#Editing-R-documentation">Editing R documentation</a>, Up: <a rel="up" accesskey="u" href="#Editing-R-documentation">Editing R documentation</a> </div> <h3 class="section">8.1 Editing R documentation (Rd) files</h3> <p>R objects are documented in files written in the <dfn>R documentation</dfn> (“Rd”), a simple markup language closely resembling (La)TeX, which can be processed into a variety of formats, including LaTeX, <acronym>HTML</acronym>, and plain text. Rd format is described in section “Rd format” of the “Writing R Extensions” manual in the R distribution. ESS has several features that facilitate editing Rd files. <p>Visiting an Rd file as characterized by its extension <samp><span class="file">Rd</span></samp> 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). <p>Note that R also accepts Rd files with extension <samp><span class="file">rd</span></samp>; to activate <acronym>ESS[Rd]</acronym> support for this extension, you may need to add <pre class="example"> (add-to-list 'auto-mode-alist '("\\.rd\\'" . Rd-mode)) </pre> <p class="noindent">to one of your Emacs startup files. <p>In Rd mode, the following special Emacs commands can be used in addition to the standard Emacs commands. <dl> <dt><kbd>C-h m</kbd><dd>Describe the features of Rd mode. <br><dt><kbd>LFD</kbd><dt><kbd>RET</kbd><dd>Reindent the current line, insert a newline and indent the new line (<code>reindent-then-newline-and-indent</code>). An abbrev before point is expanded if <code>abbrev-mode</code> is non-<code>nil</code>. <br><dt><kbd>TAB</kbd><dd>Indent current line based on its contents and on previous lines (<code>indent-according-to-mode</code>). <br><dt><kbd>C-c C-e</kbd><dd>Insert a “skeleton” with Rd markup for at least all mandatory entries in Rd files (<code>Rd-mode-insert-skeleton</code>). Note that many users might prefer to use the R function <code>prompt</code> 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). <br><dt><kbd>C-c C-f</kbd><dd>Insert “font” specifiers for some of the Rd markup commands markup available for emphasizing or quoting text, including markup for URLs and email addresses (<code>Rd-font</code>). <kbd>C-c C-f</kbd> is only a prefix; see e.g. <kbd>C-c C-f TAB</kbd> 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 <kbd>C-c C-f</kbd>. <br><dt><kbd>C-c C-j</kbd><dd>Insert a suitably indented ‘<samp><span class="samp">\item{</span></samp>’ on the next line (<code>Rd-mode-insert-item</code>). <br><dt><kbd>C-c C-p</kbd><dd>Preview a plain text version (“help file”, see <a href="#Help">Help</a>) generated from the Rd file (<code>Rd-preview-help</code>). </dl> <p>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., <kbd>C-c C-v</kbd> provides access to on-line help, and <kbd>C-c C-n</kbd> sends the current line to the R process for evaluation. This interaction is particularly useful when editing the examples in the Rd file. See <kbd>C-h m</kbd> for all available commands. <p>Rd mode also provides access to abbreviations for most of the Rd markup commands. Type <kbd>M-x list-abbrevs</kbd> with Abbrev mode turned on to list all available abbrevs. Note that all Rd abbrevs start with a grave accent. <p>Rd mode can be customized via the following variables. <dl> <dt><code>Rd-mode-hook</code><dd>Hook to be run when Rd mode is entered. <br><dt><code>Rd-indent-level</code><dd>The indentation of Rd code with respect to containing blocks. Default is 2. <br><dt><code>Rd-to-help-command</code><dd>The shell command used for converting Rd source to help text. Default is ‘<samp><span class="samp">R CMD Rd2txt</span></samp>’. </dl> <p>To automatically turn on the abbrev and font-lock features of Rd mode, add the following lines to one of your Emacs startup files: <pre class="example"> (add-hook 'Rd-mode-hook (lambda () (abbrev-mode 1) (font-lock-mode 1))) </pre> <div class="node"> <a name="Roxygen"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#R-documentation-files">R documentation files</a>, Up: <a rel="up" accesskey="u" href="#Editing-R-documentation">Editing R documentation</a> </div> <h3 class="section">8.2 Editing Roxygen documentation</h3> <p><a name="index-Roxygen-180"></a><a name="index-roxy-181"></a><a name="index-ess_002droxy-182"></a> The Roxygen R package makes it possible to keep the intended contents for Rd files as structured comments in the R source files. Roxygen can then parse R files and generate appropriate Rd files from these comments, fill the usage fields as well as updating <samp><span class="file">NAMESPACE</span></samp> files. See the Roxygen documentation found via <a href="http://roxygen.org">http://roxygen.org</a> for more information its usage. An example of an Roxygen entry for a simple R function can look like this: <pre class="example"><pre class="verbatim"> ##' Description of the function ##' ##' Further details about this function ##' @title A title ##' @param me all parameters must be listed and documented ##' @return Description of the return value ##' @author The author myfun <- function(me) cat("Hello", me, "\n") </pre> </pre> <p>The entry is immediately preceding the object to document and all lines start with the Roxygen prefix string, in this case <code>##'</code>. ESS provides support to edit these documentation entries by providing line filling, navigation, template generation etc. Syntax highlighting is provided for Emacs but not for XEmacs. <p>Roxygen is customized by the variables in the customization group “Ess Roxy”. Customizables include the Roxygen prefix, use of folding to toggle visibility of Roxygen entries and the Roxygen template. <p>All ESS Roxygen support is defined in <samp><span class="file">ess-roxy.el</span></samp> which is loaded by default in ESS. The following special Emacs commands are provided. <ul> <li><kbd>C-c C-o</kbd> (<code>ess-roxy-update-entry</code>) <br> <a name="index-ess_002droxy_002dupdate_002dentry-183"></a>Generate a Roxygen template or update the parameter list in Roxygen entry at point (or above the function at the point). Documented parameters that are not in the function are placed last in the list, parameters that are not documented and not in the definition are dropped. Parameter descriptions are filled if <code>ess-roxy-fill-param-p</code> is non-nil. <li><kbd>C-c C-e C-c</kbd> (<code>ess-roxy-toggle-roxy-region</code>) <br> <a name="index-ess_002droxy_002dtoggle_002droxy_002dregion-184"></a>Toggle the presence of the leading Roxygen string on all lines in the marked region. Convenient for transferring text to Roxygen entries and to evaluate example fields. <li><kbd>C-c C-e C-r</kbd> (<code>ess-roxy-preview-Rd</code>) <br> <a name="index-ess_002droxy_002dpreview_002dRd-185"></a>Use the attached R process to parse the entry at point to obtain the Rd code. Convenient for previewing and checking syntax. When used with the prefix argument, i.e. <kbd>C-u C-c C-e C-r</kbd>, place the content in a buffer associated with a Rd file with the same name as the documentation. Requires the Roxygen package to be installed. <li><kbd>C-c C-e C-t</kbd> (<code>ess-roxy-preview-HTML</code>) <br> <a name="index-ess_002droxy_002dpreview_002dRd-186"></a>Use the attached R process to parse the entry at to generate HTML for the entry and open it in a browser. When used with the prefix argument, i.e. <kbd>C-u C-c C-e C-t</kbd>, visit the generated HTML file instead. Requires the Roxygen and tools packages to be installed. <li><kbd>C-c C-e p</kbd> (<code>ess-roxy-previous-entry</code>) <br> <a name="index-ess_002droxy_002dprevious_002dentry-187"></a>Go to start of the Roxygen entry above point. <li><kbd>C-c C-e n</kbd> (<code>ess-roxy-next-entry</code>) <br> <a name="index-ess_002droxy_002dnext_002dentry-188"></a>Go to end of the Roxygen entry above point. <li><kbd>C-c C-e C-h</kbd> (<code>ess-roxy-hide-all</code>) <br> <a name="index-ess_002droxy_002dhide_002dall-189"></a>Use the hideshow mode to fold away the visibility of all Roxygen entries. Hide-show support must be enabled for this binding to get defined. <p>ESS also advices the following standard editing functions in order to make Roxygen editing more intuitive: <li><kbd>C-c TAB</kbd> (<code>ess-R-complete-object-name</code>) <br> <a name="index-ess_002dR_002dcomplete_002dobject_002dname-190"></a>Complete Roxygen tag at point. E.g. doing <kbd>C-c TAB</kbd> when the point is at the end of <code>@par</code> completes to <code>@param</code>. <li><kbd>M-h</kbd> (<code>mark-paragraph</code>) <br> <a name="index-mark_002dparagraph-191"></a>If the transient mark mode is active, place mark and point at start end end of the field at point and activate the mark. <li><kbd>TAB</kbd> (<code>ess-indent-command</code>) <br> <a name="index-ess_002dindent_002dcommand-192"></a>If hide-show support is enabled, fold away the visibility of the Roxygen entry at point. <li><kbd>M-q</kbd> (<code>fill-paragraph</code>) <br> <a name="index-fill_002dparagraph-193"></a>Fill the Roxygen field at point. <li><kbd>C-a</kbd> (<code>move-beginning-of-line</code>) <br> <a name="index-move_002dbeginning_002dof_002dline-194"></a>Move to the point directly to the right of the Roxygen start string. <li><kbd>ENTER</kbd> (<code>newline-and-indent</code>) <br> <a name="index-newline_002dand_002dindent-195"></a>Insert a new line and the Roxygen prefix string. </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Help"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS-for-SAS">ESS for SAS</a>, Previous: <a rel="previous" accesskey="p" href="#Editing-R-documentation">Editing R documentation</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">9 Reading help files</h2> <p><a name="index-help-files-196"></a> 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 <kbd>C-c C-v</kbd> (<code>ess-display-help-on-object</code>) <a name="index-ess_002ddisplay_002dhelp_002don_002dobject-197"></a>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. <p>If the requested object has documentation, you will be popped into a buffer (named <code>*help(</code><var>obj-name</var><code>)*</code>) 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: <ul> Help commands: <li><kbd>?</kbd> (<code>ess-describe-help-mode</code>) <br> <a name="index-ess_002ddescribe_002dhelp_002dmode-198"></a>Pops up a help buffer with a list of the commands available in S help mode. <li><kbd>h</kbd> (<code>ess-display-help-on-object</code>) <br> <a name="index-ess_002ddisplay_002dhelp_002don_002dobject-199"></a>Pop up a help buffer for a different object <p>Paging commands: <p><a name="index-paging-commands-in-help-buffers-200"></a><li><kbd>b</kbd> or <kbd>DEL</kbd> (<code>scroll-down</code>) <br> Move one page backwards through the help file. <li><kbd>SPC</kbd> (<code>scroll-up</code>) <br> Move one page forwards through the help file. <li><kbd>></kbd> (<code>beginning-of-buffer</code>) and <kbd><</kbd> (<code>end-of-buffer</code>) <br> Move to the beginning and end of the help file, respectively. <p>Section-based motion commands: <li><kbd>n</kbd> (<code>ess-skip-to-next-section</code>) and <kbd>p</kbd> (<code>ess-skip-to-previous-section</code>) <br> Move to the next and previous <a name="index-ess_002dskip_002dto_002dnext_002dsection-201"></a><a name="index-ess_002dskip_002dto_002dprevious_002dsection-202"></a>section header in the help file, respectively. A section header consists of a number of capitalized words, followed by a colon. <p>In addition, the <kbd>s</kbd> 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., ‘<samp><span class="samp">Description:</span></samp>’ instead of ‘<samp><span class="samp">DESCRIPTION:</span></samp>’ and also only some versions of S(-plus) have sections ‘<samp><span class="samp">BACKGROUND</span></samp>’, ‘<samp><span class="samp">BUGS</span></samp>’, ‘<samp><span class="samp">OPTIONAL ARGUMENTS</span></samp>’, ‘<samp><span class="samp">REQUIRED ARGUMENTS</span></samp>’, and ‘<samp><span class="samp">SIDE EFFECTS</span></samp>’. <!-- The bindings are all in ../lisp/ess-s-l.el --> <!-- ess-help-*-sec-keys-alist --> <!-- S-plus only: --> <!-- @item b BACKGROUND: --> <!-- @item B BUGS: --> <!-- @item O OPTIONAL ARGUMENTS: --> <!-- @item R REQUIRED ARGUMENTS: --> <!-- S and S-plus only: --> <!-- @item S SIDE EFFECTS: --> <p>Do use <kbd>s ?</kbd> to get the current list of active key bindings. <a name="index-ess_002dskip_002dto_002dhelp_002dsection-203"></a> <dl> <dt>‘<samp><span class="samp">a</span></samp>’<dd>ARGUMENTS: <br><dt>‘<samp><span class="samp">b</span></samp>’<dd>BACKGROUND: <br><dt>‘<samp><span class="samp">B</span></samp>’<dd>BUGS: <br><dt>‘<samp><span class="samp">d</span></samp>’<dd>DESCRIPTION: <br><dt>‘<samp><span class="samp">D</span></samp>’<dd>DETAILS: <br><dt>‘<samp><span class="samp">e</span></samp>’<dd>EXAMPLES: <br><dt>‘<samp><span class="samp">n</span></samp>’<dd>NOTE: <br><dt>‘<samp><span class="samp">O</span></samp>’<dd>OPTIONAL ARGUMENTS: <br><dt>‘<samp><span class="samp">R</span></samp>’<dd>REQUIRED ARGUMENTS: <br><dt>‘<samp><span class="samp">r</span></samp>’<dd>REFERENCES: <br><dt>‘<samp><span class="samp">s</span></samp>’<dd>SEE ALSO: <br><dt>‘<samp><span class="samp">S</span></samp>’<dd>SIDE EFFECTS: <br><dt>‘<samp><span class="samp">u</span></samp>’<dd>USAGE: <br><dt>‘<samp><span class="samp">v</span></samp>’<dd>VALUE: <br><dt>‘<samp><span class="samp"><</span></samp>’<dd>Jumps to beginning of file <br><dt>‘<samp><span class="samp">></span></samp>’<dd>Jumps to end of file <br><dt>‘<samp><span class="samp">?</span></samp>’<dd>Pops up a help buffer with a list of the defined section motion keys. </dl> <p>Miscellaneous: <li><kbd>l</kbd> (<code>ess-eval-line-and-step</code>) <br> <a name="index-ess_002deval_002dline_002dand_002dstep-204"></a>Evaluates the current line in the ESS process, and moves to the next line. Useful for running examples in help files. <li><kbd>r</kbd> (<code>ess-eval-region</code>) <br> <a name="index-ess_002deval_002dregion-205"></a>Send the contents of the current region to the ESS process. Useful for running examples in help files. <li><kbd>/</kbd> (<code>isearch-forward</code>) <br> Same as <kbd>C-s</kbd>. <p>Quit commands: <li><kbd>q</kbd> (<code>ess-switch-to-end-of-ESS</code>) <br> <a name="index-ess_002dswitch_002dto_002dend_002dof_002dESS-206"></a>Returns to the ESS process buffer in another window, leaving the help window visible. <li><kbd>k</kbd> (<code>kill-buffer</code>) <br> Kills the help buffer. <li><kbd>x</kbd> (<code>ess-kill-buffer-and-go</code>) <br> Return to the ESS process, killing this help buffer. </ul> <p>In addition, all of the ESS commands available in the edit buffers are also available in S help mode (see <a href="#Edit-buffer">Edit buffer</a>). Of course, the usual (non-editing) Emacs commands are available, and for convenience the digits and <-> act as prefix arguments. <p>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 <kbd>C-u</kbd>) to <code>ess-display-help-on-object</code>. <p>Help buffers are marked as temporary buffers in ESS, and are deleted when <code>ess-quit</code> or <code>ess-cleanup</code> are called. <p>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 <code>ess-help-own-frame</code>. <p><a name="index-ess_002dquit-207"></a><a name="index-ess_002dcleanup-208"></a><a name="index-temporary-buffers-209"></a> <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS-for-SAS"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS-for-BUGS">ESS for BUGS</a>, Previous: <a rel="previous" accesskey="p" href="#Help">Help</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">10 ESS for SAS</h2> <ul class="menu"> <li><a accesskey="1" href="#ESS_0028SAS_0029_002d_002dDesign-philosophy">ESS(SAS)--Design philosophy</a> <li><a accesskey="2" href="#ESS_0028SAS_0029_002d_002dEditing-files">ESS(SAS)--Editing files</a> <li><a accesskey="3" href="#ESS_0028SAS_0029_002d_002dTAB-key">ESS(SAS)--TAB key</a> <li><a accesskey="4" href="#ESS_0028SAS_0029_002d_002dBatch-SAS-processes">ESS(SAS)--Batch SAS processes</a> <li><a accesskey="5" href="#ESS_0028SAS_0029_002d_002dFunction-keys-for-batch-processing">ESS(SAS)--Function keys for batch processing</a> <li><a accesskey="6" href="#iESS_0028SAS_0029_002d_002dInteractive-SAS-processes">iESS(SAS)--Interactive SAS processes</a> <li><a accesskey="7" href="#iESS_0028SAS_0029_002d_002dCommon-problems">iESS(SAS)--Common problems</a> <li><a accesskey="8" href="#ESS_0028SAS_0029_002d_002dGraphics">ESS(SAS)--Graphics</a> <li><a accesskey="9" href="#ESS_0028SAS_0029_002d_002dWindows">ESS(SAS)--Windows</a> </ul> <p><acronym>ESS[SAS]</acronym> was designed for use with <acronym>SAS</acronym><!-- /@w -->. It is descended from emacs macros developed by John Sall for editing <acronym>SAS</acronym><!-- /@w --> programs and <code>SAS-mode</code> by Tom Cook. Those editing features and new advanced features are part of <acronym>ESS[SAS]</acronym>. The user interface of <acronym>ESS[SAS]</acronym> has similarities with <acronym>ESS[S]</acronym> and the <acronym>SAS</acronym><!-- /@w --> Display Manager. <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(SAS)--Design-philosophy"></a> <a name="ESS_0028SAS_0029_002d_002dDesign-philosophy"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS_0028SAS_0029_002d_002dEditing-files">ESS(SAS)--Editing files</a>, Previous: <a rel="previous" accesskey="p" href="#ESS-for-SAS">ESS for SAS</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-SAS">ESS for SAS</a> </div> <h3 class="section">10.1 ESS(SAS)–Design philosophy</h3> <p><acronym>ESS[SAS]</acronym> was designed to aid the user in writing and maintaining <acronym>SAS</acronym><!-- /@w --> programs, such as <samp><var>foo</var><span class="file">.sas</span></samp>. Both interactive and batch submission of <acronym>SAS</acronym><!-- /@w --> programs is supported. <p><acronym>ESS[SAS]</acronym> was written with two primary goals. <ol type=1 start=1> <li>The emacs text editor provides a powerful and flexible development environment for programming languages. These features are a boon to all programmers and, with the help of <acronym>ESS[SAS]</acronym>, to <acronym>SAS</acronym><!-- /@w --> users as well. <li>Although a departure from <acronym>SAS</acronym><!-- /@w --> Display Manager, <acronym>ESS[SAS]</acronym> provides similar key definitions to give novice <acronym>ESS[SAS]</acronym> users a head start. Also, inconvenient <acronym>SAS</acronym><!-- /@w --> Display Manager features, like remote submission and syntax highlighting, are provided transparently; appealing to advanced <acronym>ESS[SAS]</acronym> users. </ol> <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(SAS)--Editing-files"></a> <a name="ESS_0028SAS_0029_002d_002dEditing-files"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS_0028SAS_0029_002d_002dTAB-key">ESS(SAS)--TAB key</a>, Previous: <a rel="previous" accesskey="p" href="#ESS_0028SAS_0029_002d_002dDesign-philosophy">ESS(SAS)--Design philosophy</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-SAS">ESS for SAS</a> </div> <h3 class="section">10.2 ESS(SAS)–Editing files</h3> <p><acronym>ESS[SAS]</acronym> is the mode for editing <acronym>SAS</acronym><!-- /@w --> language files. This mode handles: <ul> <li>proper indenting, generated by both <TAB> and <RET>. <li>color and font choices based on syntax. <li>ability to save and submit the file you are working on as a batch <acronym>SAS</acronym><!-- /@w --> process with a single keypress and to continue editing while it is runs in the background. <li>capability of killing the batch <acronym>SAS</acronym><!-- /@w --> process through the <samp><span class="file">*shell*</span></samp> buffer or allow the <acronym>SAS</acronym><!-- /@w --> process to keep on running after you exit emacs. <li>single keypress navigation of <samp><span class="file">.sas</span></samp>, <samp><span class="file">.log</span></samp> and <samp><span class="file">.lst</span></samp> files (<samp><span class="file">.log</span></samp> and <samp><span class="file">.lst</span></samp> files are refreshed with each keypress). <li>ability to send the contents of an entire buffer, a highlighted region, or a single line to an interactive <acronym>SAS</acronym><!-- /@w --> process. <li>ability to switch between processes which would be the target of the buffer (for the above). </ul> <p><acronym>ESS[SAS]</acronym> is automatically turned on when editing a file with a <samp><span class="file">.sas</span></samp> suffix (or other extension, if specified via <code>auto-mode-alist</code>). The function keys can be enabled to use the same function keys that the <acronym>SAS</acronym><!-- /@w --> Display Manager does. The interactive capabilities of <acronym>ESS</acronym> require you to start an inferior <acronym>SAS</acronym><!-- /@w --> process with <kbd>M-x SAS</kbd><!-- /@w --> (See <a href="#iESS_0028SAS_0029_002d_002dInteractive-SAS-processes">iESS(SAS)–Interactive SAS processes</a>.) <p>At this writing, the indenting and syntax highlighting are generally correct. Known issues: for multiple line <code>*</code> or <code>%*</code> comments, only the first line is highlighted; for <samp><span class="file">.log</span></samp> files, only the first line of a <code>NOTE:</code>, <code>WARNING:</code> or <code>ERROR:</code> message is highlighted; unmatched single/double quotes in <code>CARDS</code> data lines are <strong>NOT</strong> ignored; in an iterative <code>DO</code> statement, <code>TO</code> and <code>BY</code> are not highlighted. <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(SAS)--TAB-key"></a> <a name="ESS_0028SAS_0029_002d_002dTAB-key"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS_0028SAS_0029_002d_002dBatch-SAS-processes">ESS(SAS)--Batch SAS processes</a>, Previous: <a rel="previous" accesskey="p" href="#ESS_0028SAS_0029_002d_002dEditing-files">ESS(SAS)--Editing files</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-SAS">ESS for SAS</a> </div> <h3 class="section">10.3 ESS(SAS)–<TAB> key</h3> <p>Two options. The <TAB> key is bound by default to <code>sas-indent-line</code>. This function is used to syntactically indent <acronym>SAS</acronym><!-- /@w --> code so <code>PROC</code> and <code>RUN</code> are in the left margin, other statements are indented <code>sas-indent-width</code> spaces from the margin, continuation lines are indented <code>sas-indent-width</code> 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 activated by placing the following line in your initialization file prior to a <code>require</code>/<code>load</code>: <pre class="example"> (setq ess-sas-edit-keys-toggle nil) </pre> <p><acronym>ESS</acronym> provides an alternate behavior for <TAB> that makes it behave as it does in <acronym>SAS</acronym><!-- /@w --> Display Manager, i.e. move the cursor to the next stop. The alternate behavior also provides a "TAB" backwards, <kbd>C-<TAB></kbd><!-- /@w -->, that moves the cursor to the stop to the left and deletes any characters between them. This functionality is obtained by placing the following line in your initialization file prior to a <code>require</code>/<code>load</code>: <pre class="example"> (setq ess-sas-edit-keys-toggle t) </pre> <p>Under the alternate behavior, <TAB> is bound to <kbd>M-x tab-to-tab-stop</kbd><!-- /@w --> and the stops are defined by <code>ess-sas-tab-stop-list</code>. <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(SAS)--Batch-SAS-processes"></a> <a name="ESS_0028SAS_0029_002d_002dBatch-SAS-processes"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS_0028SAS_0029_002d_002dFunction-keys-for-batch-processing">ESS(SAS)--Function keys for batch processing</a>, Previous: <a rel="previous" accesskey="p" href="#ESS_0028SAS_0029_002d_002dTAB-key">ESS(SAS)--TAB key</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-SAS">ESS for SAS</a> </div> <h3 class="section">10.4 ESS(SAS)–Batch SAS processes</h3> <p>Submission of a <acronym>SAS</acronym><!-- /@w --> batch job is dependent on your environment. <code>ess-sas-submit-method</code> is determined by your operating system and your shell. It defaults to <code>'sh</code> unless you are running Windows or Mac Classic. Under Windows, it will default to <code>'sh</code> if you are using a <acronym>UNIX</acronym>-imitating shell; otherwise <code>'ms-dos</code> for an <acronym>MS-DOS</acronym> shell. On Mac OS X, it will default to <code>'sh</code>, but under Mac Classic, it defaults to <code>'apple-script</code>. You will also set this to <code>'sh</code> if the <acronym>SAS</acronym><!-- /@w --> 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 <code>ess-sas-shell-buffer-remote-init</code> is a Local Variable that defaults to <code>"ssh"</code> 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 <code>ssh-agent</code>/<code>ssh-add</code> or the equivalent (see the discussion about Local Variables below if you need to change the default). <p>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 <code>ess-kermit-prefix</code> character prepended (the default is <code>"#"</code>). Execute the command <kbd>M-x ess-kermit-get</kbd><!-- /@w --> which automatically brings the contents of the remote file into your local copy. If you transfer files with Kermit manually in a <samp><span class="file">*shell*</span></samp> buffer, then note that the Kermit escape sequence is <kbd>C-q C- c</kbd><!-- /@w --> rather than <kbd>C- c</kbd><!-- /@w --> 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 <code>ess-kermit-command</code>. <p>The command used by the <code>SUBMIT</code> function key (<F3> or <F8>) to submit a batch <acronym>SAS</acronym><!-- /@w --> job, whether local or remote, is <code>ess-sas-submit-command</code> which defaults to <code>sas-program</code>. <code>sas-program</code> is <code>"invoke SAS using program file"</code> for Mac Classic and <code>"sas"</code> otherwise. However, you may have to alter <code>ess-sas-submit-command</code> for a particular program, so it is defined as buffer-local. Conveniently, it can be set at the end of the program: <pre class="example"> endsas; Local variables: ess-sas-submit-command: "sas8" End: </pre> <p>The command line is also made of <code>ess-sas-submit-pre-command</code>, <code>ess-sas-submit-post-command</code> and <code>ess-sas-submit-command-options</code> (the last of which is also buffer-local). Here are some examples for your <samp><span class="file">~/.emacs</span></samp> or <samp><span class="file">~/.xemacs/init.el</span></samp> file (you may also use <kbd>M-x customize-variable</kbd><!-- /@w -->): <pre class="example"> ;'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") </pre> <p>There is a built-in delay before a batch <acronym>SAS</acronym><!-- /@w --> job is submitted when using a <acronym>UNIX</acronym>-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 <samp><span class="file">~/.emacs</span></samp> or <samp><span class="file">~/.xemacs/init.el</span></samp> file by: <pre class="example"> (setq ess-sleep-for 0.2) </pre> <p>For example, <code>(setq ess-sas-global-unix-keys t)</code> keys shown, <code>(setq ess-sas-global-pc-keys t)</code> in parentheses; <acronym>ESS[SAS]</acronym> function keys are presented in the next section. Open the file you want to work with <kbd>C-x C-f foo.sas</kbd><!-- /@w -->. <samp><var>foo</var><span class="file">.sas</span></samp> will be in <acronym>ESS[SAS]</acronym> mode. Edit as appropriate, then save and submit the batch <acronym>SAS</acronym><!-- /@w --> job. <pre class="example"> <F3> (<F8>) </pre> <p>The job runs in the <samp><span class="file">*shell*</span></samp> buffer while you continue to edit <samp><var>foo</var><span class="file">.sas</span></samp>. If <code>ess-sas-submit-method</code> is <code>'sh</code>, then the message buffer will display the shell notification when the job is complete. The <code>'sh</code> setting also allows you to terminate the <acronym>SAS</acronym><!-- /@w --> batch job before it is finished. <pre class="example"> <F8> (<F3>) </pre> <p>Terminating a <acronym>SAS</acronym><!-- /@w --> batch in the <samp><span class="file">*shell*</span></samp> buffer. <pre class="example"> kill <var>PID</var> </pre> <p>You may want to visit the <samp><span class="file">.log</span></samp> (whether the job is still running or it is finished) and check for error messages. The <samp><span class="file">.log</span></samp> will be refreshed and you will be placed in it's buffer. You will be taken to the first error message, if any. <pre class="example"> <F5> (<F6>) </pre> <p>Goto the next error message, if any. <pre class="example"> <F5> (<F6>) </pre> <p>Now, ‘<samp><span class="samp">refresh</span></samp>’ the <samp><span class="file">.lst</span></samp> and go to it's buffer. <pre class="example"> <F6> (<F7>) </pre> <p>If you wish to make changes, go to the <samp><span class="file">.sas</span></samp> file with. <pre class="example"> <F4> (<F5>) </pre> <p>Make your editing changes and submit again. <pre class="example"> <F3> (<F8>) </pre> <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(SAS)--Function-keys-for-batch-processing"></a> <a name="ESS_0028SAS_0029_002d_002dFunction-keys-for-batch-processing"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#iESS_0028SAS_0029_002d_002dInteractive-SAS-processes">iESS(SAS)--Interactive SAS processes</a>, Previous: <a rel="previous" accesskey="p" href="#ESS_0028SAS_0029_002d_002dBatch-SAS-processes">ESS(SAS)--Batch SAS processes</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-SAS">ESS for SAS</a> </div> <h3 class="section">10.5 ESS(SAS)–Function keys for batch processing</h3> <p>The setup of function keys for <acronym>SAS</acronym><!-- /@w --> batch processing is unavoidably complex, but the usage of function keys is simple. There are five distinct options: <p>Option 1 (default). Function keys in <acronym>ESS[SAS]</acronym> are not bound to elisp commands. This is in accordance with the GNU Elisp Coding Standards (<acronym>GECS</acronym>) which do not allow function keys to be bound so that they are available to the user. <p>Options 2-5. Since <acronym>GECS</acronym> does not allow function keys to be bound by modes, these keys are often unused. So, <acronym>ESS[SAS]</acronym> provides users with the option of binding elisp commands to these keys. Users who are familiar with <acronym>SAS</acronym><!-- /@w --> will, most likely, want to duplicate the function key capabilities of the <acronym>SAS</acronym><!-- /@w --> Display Manager. There are four options (noted in parentheses). <ol type=a start=1> <li><acronym>SAS</acronym><!-- /@w --> Display Manager has different function key definitions for <acronym>UNIX</acronym> (2, 4) and Windows (3, 5); <acronym>ESS[SAS]</acronym> can use either. <li>The <acronym>ESS[SAS]</acronym> function key definitions can be active in all buffers (global: 4, 5) or limited (local: 2, 3) only to buffers with files that are associated with <acronym>ESS[SAS]</acronym> as specified in your <code>auto-mode-alist</code>. </ol> <p>The distinction between local and global is subtle. If you want the <acronym>ESS[SAS]</acronym> definitions to work when you are in the <samp><span class="file">*shell*</span></samp> buffer or when editing files other than the file extensions that <acronym>ESS[SAS]</acronym> recognizes, you will most likely want to use the global definitions. If you want your function keys to understand <acronym>SAS</acronym><!-- /@w --> batch commands when you are editing <acronym>SAS</acronym><!-- /@w --> 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 <acronym>ESS</acronym> for a site or by an individual. <ol type=a start=1> <li>For a site installation or an individual, place <strong>ONLY ONE</strong> of the following lines in your initialization file prior to a <code>require</code>/<code>load</code>. <acronym>ESS[SAS]</acronym> function keys are available in <acronym>ESS[SAS]</acronym> if you choose either 2 or 3 and in all modes if you choose 4 or 5: <pre class="example"> ;;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) </pre> <p>The names <code>-unix-</code> and <code>-pc-</code> have nothing to do with the operating system that you are running. Rather, they mimic the definitions that the <acronym>SAS</acronym><!-- /@w --> Display Manager uses by default on those platforms. <li>If your site installation has configured the keys contrary to your liking, then you must call the appropriate function. <pre class="example"> (load "ess-site") ;; local-unix-keys (ess-sas-global-pc-keys) </pre> </ol> <p>Finally, we get to what the function keys actually do. You may recognize some of the nicknames as <acronym>SAS</acronym><!-- /@w --> Display Manager commands (they are in all capitals). <p><table summary=""><tr align="left"><td valign="top"><acronym>UNIX</acronym> </td><td valign="top"><acronym>PC</acronym> </td><td valign="top">Nickname <br></td></tr><tr align="left"><td valign="top"><F2> </td><td valign="top"><F2> </td><td valign="top">‘<samp><span class="samp">refresh</span></samp>’ <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> revert the current buffer with the file of the same name if the file is newer than the buffer <br></td></tr><tr align="left"><td valign="top"><F3> </td><td valign="top"><F8> </td><td valign="top"><code>SUBMIT</code> <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> save the current <samp><span class="file">.sas</span></samp> file (which is either the <samp><span class="file">.sas</span></samp> file in the current buffer or the <samp><span class="file">.sas</span></samp> file associated with the <samp><span class="file">.lst</span></samp> or <samp><span class="file">.log</span></samp> file in the current buffer) and submit the file as a batch <acronym>SAS</acronym><!-- /@w --> job <br></td></tr><tr align="left"><td valign="top"><F4> </td><td valign="top"><F5> </td><td valign="top"><code>PROGRAM</code> <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> switch buffer to <samp><span class="file">.sas</span></samp> file <br></td></tr><tr align="left"><td valign="top"><F5> </td><td valign="top"><F6> </td><td valign="top"><code>LOG</code> <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> switch buffer to <samp><span class="file">.log</span></samp> file, ‘<samp><span class="samp">refresh</span></samp>’ and goto next error message, if any <br></td></tr><tr align="left"><td valign="top"><F6> </td><td valign="top"><F7> </td><td valign="top"><code>OUTPUT</code> <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> switch buffer to <samp><span class="file">.lst</span></samp> file and ‘<samp><span class="samp">refresh</span></samp>’ <br></td></tr><tr align="left"><td valign="top"><F7> </td><td valign="top"><F4> </td><td valign="top">‘<samp><span class="samp">filetype-1</span></samp>’ <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> switch buffer to ‘<samp><span class="samp">filetype-1</span></samp>’ (defaults to <samp><span class="file">.txt</span></samp>) file and ‘<samp><span class="samp">refresh</span></samp>’ <br></td></tr><tr align="left"><td valign="top"><F8> </td><td valign="top"><F3> </td><td valign="top">‘<samp><span class="samp">shell</span></samp>’ <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> switch buffer to <samp><span class="file">*shell*</span></samp> <br></td></tr><tr align="left"><td valign="top"><F9> </td><td valign="top"><F9> </td><td valign="top"><code>VIEWTABLE</code> <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> open an interactive <code>PROC FSEDIT</code> session on the <acronym>SAS</acronym><!-- /@w --> dataset near point <br></td></tr><tr align="left"><td valign="top"><F10> </td><td valign="top"><F10> </td><td valign="top">toggle-log <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> toggle <acronym>ESS[SAS]</acronym> for <samp><span class="file">.log</span></samp> files; useful for certain debugging situations <br></td></tr><tr align="left"><td valign="top"><F11> </td><td valign="top"><F11> </td><td valign="top">‘<samp><span class="samp">filetype-2</span></samp>’ <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> switch buffer to ‘<samp><span class="samp">filetype-2</span></samp>’ (defaults to <samp><span class="file">.dat</span></samp>) file and ‘<samp><span class="samp">refresh</span></samp>’ <br></td></tr><tr align="left"><td valign="top"><F12> </td><td valign="top"><F12> </td><td valign="top">viewgraph <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> open a <code>GSASFILE</code> near point for viewing either in emacs or with an external viewer <br></td></tr><tr align="left"><td valign="top"><kbd>C-<F1></kbd> </td><td valign="top"><kbd>C-<F1></kbd> </td><td valign="top">rtf-portrait <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> create an <span class="sc">MS RTF</span> portrait file from the current buffer with a file extension of <samp><span class="file">.rtf</span></samp> <br></td></tr><tr align="left"><td valign="top"><kbd>C-<F2></kbd> </td><td valign="top"><kbd>C-<F2></kbd> </td><td valign="top">rtf-landscape <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> create an <span class="sc">MS RTF</span> landscape file from the current buffer with a file extension of <samp><span class="file">.rtf</span></samp> <br></td></tr><tr align="left"><td valign="top"><kbd>C-<F3></kbd> </td><td valign="top"><kbd>C-<F8></kbd> </td><td valign="top">submit-region <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> write region to <samp><span class="file">ess-temp.sas</span></samp> and submit <br></td></tr><tr align="left"><td valign="top"><kbd>C-<F5></kbd> </td><td valign="top"><kbd>C-<F6></kbd> </td><td valign="top">append-to-log <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> append <samp><span class="file">ess-temp.log</span></samp> to the current <samp><span class="file">.log</span></samp> file <br></td></tr><tr align="left"><td valign="top"><kbd>C-<F6></kbd> </td><td valign="top"><kbd>C-<F7></kbd> </td><td valign="top">append-to-output <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> append <samp><span class="file">ess-temp.lst</span></samp> to the current <samp><span class="file">.lst</span></samp> file <br></td></tr><tr align="left"><td valign="top"><kbd>C-<F9></kbd> </td><td valign="top"><kbd>C-<F9></kbd> </td><td valign="top"><code>INSIGHT</code> <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> open an interactive <code>PROC INSIGHT</code> session on the <acronym>SAS</acronym><!-- /@w --> dataset near point <br></td></tr><tr align="left"><td valign="top"><kbd>C-<F10></kbd> </td><td valign="top"><kbd>C-<F10></kbd> </td><td valign="top">toggle-listing <br></td></tr><tr align="left"><td valign="top"></td><td valign="top"></td><td valign="top"> toggle <acronym>ESS[SAS]</acronym> for <samp><span class="file">.lst</span></samp> files; useful for toggling read-only <br></td></tr></table> <p><code>SUBMIT</code>, <code>PROGRAM</code>, <code>LOG</code> and <code>OUTPUT</code> need no further explanation since they mimic the <acronym>SAS</acronym><!-- /@w --> Display Manager commands and related function key definitions. However, six other keys have been provided for convenience and are described below. <p>‘<samp><span class="samp">shell</span></samp>’ switches you to the <samp><span class="file">*shell*</span></samp> buffer where you can interact with your operating system. This is especially helpful if you would like to kill a <acronym>SAS</acronym><!-- /@w --> batch job. You can specify a different buffer name to associate with a <acronym>SAS</acronym><!-- /@w --> batch job (besides <samp><span class="file">*shell*</span></samp>) with the buffer-local variable <code>ess-sas-shell-buffer</code>. This allows you to have multiple buffers running <acronym>SAS</acronym><!-- /@w --> batch jobs on multiple local/remote computers that may rely on different methods specified by the buffer-local variable <code>ess-sas-submit-method</code>. <p><F2> performs the ‘<samp><span class="samp">refresh</span></samp>’ operation on the current buffer. ‘<samp><span class="samp">refresh</span></samp>’ 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 <code>LOG</code>, <code>OUTPUT</code>, ‘<samp><span class="samp">filetype-1</span></samp>’ or <F11> are pressed. <p>‘<samp><span class="samp">filetype-1</span></samp>’ switches you to a file with the same file name as your <samp><span class="file">.sas</span></samp> file, but with a different extension (<samp><span class="file">.txt</span></samp> by default) and performs ‘<samp><span class="samp">refresh</span></samp>’. You can over-ride the default extension; for example in your <samp><span class="file">~/.emacs</span></samp> or <samp><span class="file">~/.xemacs/init.el</span></samp> file: <pre class="example"> (setq ess-sas-suffix-1 "csv") ; for example </pre> <p><F9> will prompt you for the name of a permanent <acronym>SAS</acronym><!-- /@w --> dataset near point to be opened for viewing by <code>PROC FSEDIT</code>. You can control the <acronym>SAS</acronym><!-- /@w --> batch command-line with <code>ess-sas-data-view-submit-options</code>. For controlling the <acronym>SAS</acronym><!-- /@w --> batch commands, you have the global variables <code>ess-sas-data-view-libname</code> and <code>ess-sas-data-view-fsview-command</code> as well as the buffer-local variable <code>ess-sas-data-view-fsview-statement</code>. If you have your <acronym>SAS</acronym><!-- /@w --> <code>LIBNAME</code> defined in <samp><span class="file">~/autoexec.sas</span></samp>, then the defaults for these variables should be sufficient. <p>Similarly, <kbd>C-<F9></kbd><!-- /@w --> will prompt you for the name of a permanent <acronym>SAS</acronym><!-- /@w --> dataset near point to be opened for viewing by <code>PROC INSIGHT</code>. You can control the <acronym>SAS</acronym><!-- /@w --> batch command-line with <code>ess-sas-data-view-submit-options</code>. For controlling the <acronym>SAS</acronym><!-- /@w --> batch commands, you have the global variables <code>ess-sas-data-view-libname</code> and <code>ess-sas-data-view-insight-command</code> as well as the buffer-local variable <code>ess-sas-data-view-insight-statement</code>. <p><F10> toggles <acronym>ESS[SAS]</acronym> mode for <samp><span class="file">.log</span></samp> files which is off by default (technically, it is <code>SAS-log-mode</code>, but it looks the same). The syntax highlighting can be helpful in certain debugging situations, but large <samp><span class="file">.log</span></samp> files may take a long time to highlight. <p><F11> is the same as ‘<samp><span class="samp">filetype-1</span></samp>’ except it is <samp><span class="file">.dat</span></samp> by default. <p><F12> will prompt you for the name of a <code>GSASFILE</code> near the point in <samp><span class="file">.log</span></samp> 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 <samp><span class="file">.gif</span></samp> and <samp><span class="file">.jpg</span></samp> files internally. You may need to change the following variables for your own situation. <code>ess-sas-graph-view-suffix-regexp</code> is a regular expression of supported file types defined via file name extensions. <code>ess-sas-graph-view-viewer-default</code> is the default external viewer for your platform. <code>ess-sas-graph-view-viewer-alist</code> 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. <pre class="example"> (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 </pre> <p><kbd>C-<F2></kbd><!-- /@w --> produces US landscape by default, however, it can produce A4 landscape (first line for "global" key mapping, second for "local"): <pre class="example"> (global-set-key [(control f2)] 'ess-sas-rtf-a4-landscape) (define-key sas-mode-local-map [(control f2)] 'ess-sas-rtf-a4-landscape) </pre> <!-- node-name, next, previous, up --> <div class="node"> <a name="iESS(SAS)--Interactive-SAS-processes"></a> <a name="iESS_0028SAS_0029_002d_002dInteractive-SAS-processes"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#iESS_0028SAS_0029_002d_002dCommon-problems">iESS(SAS)--Common problems</a>, Previous: <a rel="previous" accesskey="p" href="#ESS_0028SAS_0029_002d_002dFunction-keys-for-batch-processing">ESS(SAS)--Function keys for batch processing</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-SAS">ESS for SAS</a> </div> <h3 class="section">10.6 iESS(SAS)–Interactive SAS processes</h3> <p>Inferior <acronym>ESS</acronym> (i<acronym>ESS</acronym><!-- /@w -->) is the method for interfacing with interactive statistical processes (programs). i<acronym>ESS[SAS]</acronym><!-- /@w --> is what is needed for interactive <acronym>SAS</acronym><!-- /@w --> programming. i<acronym>ESS[SAS]</acronym><!-- /@w --> works best with the <acronym>SAS</acronym><!-- /@w --> command-line option settings <code>"-stdio -linesize 80 -noovp -nosyntaxcheck"</code> (the default of <code>inferior-SAS-args</code>). <pre class="display"> <code>-stdio</code> required to make the redirection of stdio work <code>-linesize 80</code> keeps output lines from folding on standard terminals <code>-noovp</code> prevents error messages from printing 3 times <code>-nosyntaxcheck</code> permits recovery after syntax errors </pre> <p>To start up i<acronym>ESS[SAS]</acronym><!-- /@w --> mode, use: <pre class="example"> <kbd>M-x SAS</kbd><!-- /@w --> </pre> <p>The <samp><span class="file">*SAS:1.log*</span></samp> buffer in <code>ESStr</code> mode corresponds to the file <samp><var>foo</var><span class="file">.log</span></samp> in <acronym>SAS</acronym><!-- /@w --> batch usage and to the ‘<samp><span class="samp">SAS: LOG</span></samp>’ window in the <acronym>SAS</acronym><!-- /@w --> Display Manager. All commands submitted to <acronym>SAS</acronym><!-- /@w -->, informative messages, warnings, and errors appear here. <p>The <samp><span class="file">*SAS:1.lst*</span></samp> buffer in <code>ESSlst</code> mode corresponds to the file <samp><var>foo</var><span class="file">.lst</span></samp> in <acronym>SAS</acronym><!-- /@w --> batch usage and to the ‘<samp><span class="samp">SAS: OUTPUT</span></samp>’ window in the <acronym>SAS</acronym><!-- /@w --> Display Manager. All printed output appears in this window. <p>The <samp><span class="file">*SAS:1*</span></samp> buffer exists solely as a communications buffer. The user should never use this buffer directly. Files are edited in the <samp><var>foo</var><span class="file">.sas</span></samp> buffer. The <kbd>C-c C-r</kbd><!-- /@w --> key in <acronym>ESS[SAS]</acronym> is the functional equivalent of bringing a file into the ‘<samp><span class="samp">SAS: PROGRAM EDITOR</span></samp>’ window followed by <code>SUBMIT</code>. <p>For example, open the file you want to work with. <pre class="example"> <kbd>C-x C-f foo.sas</kbd><!-- /@w --> </pre> <p><samp><var>foo</var><span class="file">.sas</span></samp> will be in <acronym>ESS[SAS]</acronym> mode. Edit as appropriate, and then start up <acronym>SAS</acronym><!-- /@w --> with the cursor in the <samp><var>foo</var><span class="file">.sas</span></samp> buffer. <pre class="example"> <kbd>M-x SAS</kbd><!-- /@w --> </pre> <p>Four buffers will appear on screen: <p><table summary=""><tr align="left"><td valign="top">Buffer </td><td valign="top">Mode </td><td valign="top">Description <br></td></tr><tr align="left"><td valign="top"><samp><var>foo</var><span class="file">.sas</span></samp> </td><td valign="top"><code><acronym>ESS[SAS]</acronym></code> </td><td valign="top">your source file <br></td></tr><tr align="left"><td valign="top"><samp><span class="file">*SAS:1*</span></samp> </td><td valign="top"><code>i<acronym>ESS[SAS:1]</acronym><!-- /@w --></code> </td><td valign="top">i<acronym>ESS</acronym><!-- /@w --> communication buffer <br></td></tr><tr align="left"><td valign="top"><samp><span class="file">*SAS:1.log*</span></samp> </td><td valign="top"><code>Shell ESStr []</code> </td><td valign="top"><acronym>SAS</acronym><!-- /@w --> log information <br></td></tr><tr align="left"><td valign="top"><samp><span class="file">*SAS:1.lst*</span></samp> </td><td valign="top"><code>Shell ESSlst []</code> </td><td valign="top"><acronym>SAS</acronym><!-- /@w --> listing information <br></td></tr></table> If you would prefer each of the four buffers to appear in its own individual frame, you can arrange for that. Place the cursor in the buffer displaying <samp><var>foo</var><span class="file">.sas</span></samp>. Enter the sequence <kbd>C-c C-w</kbd><!-- /@w -->. The cursor will normally be in buffer <samp><var>foo</var><span class="file">.sas</span></samp>. If not, put it there and <kbd>C-x b </kbd><var>foo</var><kbd>.sas</kbd><!-- /@w -->. <p>Send regions, lines, or the entire file contents to <acronym>SAS</acronym><!-- /@w --> (regions are most useful: a highlighted region will normally begin with the keywords <code>DATA</code> or <code>PROC</code> and end with <code>RUN;</code>), <kbd>C-c C-r</kbd><!-- /@w -->. <p>Information appears in the log buffer, analysis results in the listing buffer. In case of errors, make the corrections in the <samp><var>foo</var><span class="file">.sas</span></samp> buffer and resubmit with another <kbd>C-c C-r</kbd><!-- /@w -->. <p>At the end of the session you may save the log and listing buffers with the usual <kbd>C-x C-s</kbd><!-- /@w --> commands. You will be prompted for a file name. Typically, the names <samp><var>foo</var><span class="file">.log</span></samp> and <samp><var>foo</var><span class="file">.lst</span></samp> 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 <kbd>C-x C-q</kbd><!-- /@w -->. <p>At the end of the session, the input file <samp><var>foo</var><span class="file">.sas</span></samp> will typically have been revised. You can save it. It can be used later as the beginning of another i<acronym>ESS[SAS]</acronym><!-- /@w --> session. It can also be used as a batch input file to <acronym>SAS</acronym><!-- /@w -->. <p>The <samp><span class="file">*SAS:1*</span></samp> buffer is strictly for <acronym>ESS</acronym> use. The user should never need to read it or write to it. Refer to the <samp><span class="file">.lst</span></samp> and <samp><span class="file">.log</span></samp> buffers for monitoring output! <p>Troubleshooting: See <a href="#iESS_0028SAS_0029_002d_002dCommon-problems">iESS(SAS)–Common problems</a>. <!-- node-name, next, previous, up --> <div class="node"> <a name="iESS(SAS)--Common-problems"></a> <a name="iESS_0028SAS_0029_002d_002dCommon-problems"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS_0028SAS_0029_002d_002dGraphics">ESS(SAS)--Graphics</a>, Previous: <a rel="previous" accesskey="p" href="#iESS_0028SAS_0029_002d_002dInteractive-SAS-processes">iESS(SAS)--Interactive SAS processes</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-SAS">ESS for SAS</a> </div> <h3 class="section">10.7 iESS(SAS)–Common problems</h3> <ol type=1 start=1> <li>i<acronym>ESS[SAS]</acronym><!-- /@w --> does not work on Windows. In order to run <acronym>SAS</acronym><!-- /@w --> inside an emacs buffer, it is necessary to start <acronym>SAS</acronym><!-- /@w --> with the <code>-stdio</code> option. <acronym>SAS</acronym><!-- /@w --> does not support the <code>-stdio</code> option on Windows. <li>If <kbd>M-x SAS</kbd><!-- /@w --> gives errors upon startup, check the following: <ul> <li>you are running Windows: see 1. <li><samp><span class="file">ess-sas-sh-command</span></samp> (from the <acronym>ESS</acronym> <samp><span class="file">etc</span></samp> directory) needs to be executable; too check, type <kbd>M-x dired</kbd><!-- /@w -->; if not, fix it as follows, type <kbd>M-:</kbd>, then at the minibuffer prompt ‘<samp><span class="samp">Eval:</span></samp>’<!-- /@w -->, type <code>(set-file-modes "ess-sas-sh-command" 493)</code>. <!-- (solution: @code{chmod ugo+rx ess-sas-sh-command}). --> <li><code>sas</code> isn't in your executable path; to verify, type <kbd>M-:</kbd> and at the minibuffer prompt ‘<samp><span class="samp">Eval:</span></samp>’, type <code>(executable-find "sas")</code> </ul> <li><kbd>M-x SAS</kbd><!-- /@w --> starts <acronym>SAS</acronym><!-- /@w --> Display<!-- /@w --> Manager. Probably, the command <code>sas</code> on your system calls a shell script. In that case you will need to locate the real <code>sas</code> executable and link to it. You can execute the <acronym>UNIX</acronym> command: <pre class="example"> find / -name sas -print </pre> <p>Now place a soft link to the real <code>sas</code> executable in your <code>~/bin</code> directory, with for example <pre class="example"> cd ~/bin ln -s /usr/local/sas9/sas sas </pre> </ol> Check your <code>PATH</code> environment variable to confirm that <code>~/bin</code> appears before the directory in which the <code>sas</code> shell script appears. <!-- Specify the path to the real --> <!-- @code{sas} executable in @file{ess-sas-sh-command}, i.e.: --> <!-- @example --> <!-- /usr/local/sas9/sas $@@ </dev/tty 1>$stdout 2>$stderr --> <!-- @end example --> <!-- To find the @code{sas} executable, you can execute the @UNIX{} command: --> <!-- @example --> <!-- find / -name sas -print --> <!-- @end example --> <!-- @end enumerate --> <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(SAS)--Graphics"></a> <a name="ESS_0028SAS_0029_002d_002dGraphics"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS_0028SAS_0029_002d_002dWindows">ESS(SAS)--Windows</a>, Previous: <a rel="previous" accesskey="p" href="#iESS_0028SAS_0029_002d_002dCommon-problems">iESS(SAS)--Common problems</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-SAS">ESS for SAS</a> </div> <h3 class="section">10.8 ESS(SAS)–Graphics</h3> <p>Output from a <acronym>SAS/GRAPH</acronym><!-- /@w --> <code>PROC</code> can be displayed in a <acronym>SAS/GRAPH</acronym><!-- /@w --> window for <acronym>SAS</acronym><!-- /@w --> batch on Windows or for both <acronym>SAS</acronym><!-- /@w --> batch and interactive with XWindows on <acronym>UNIX</acronym>. If you need to create graphics files and view them with <F12>, then include the following (either in <samp><var>foo</var><span class="file">.sas</span></samp> or in <samp><span class="file">~/autoexec.sas</span></samp>): <pre class="example"> filename gsasfile 'graphics.ps'; goptions device=ps gsfname=gsasfile gsfmode=append; </pre> <p><code>PROC PLOT</code> 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: <pre class="example"> proc plot; plot a*b / vpos=25; run; </pre> <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(SAS)--Windows"></a> <a name="ESS_0028SAS_0029_002d_002dWindows"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#ESS_0028SAS_0029_002d_002dGraphics">ESS(SAS)--Graphics</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-SAS">ESS for SAS</a> </div> <h3 class="section">10.9 ESS(SAS)–Windows</h3> <ul> <li>i<acronym>ESS[SAS]</acronym><!-- /@w --> does not work on Windows. See <a href="#iESS_0028SAS_0029_002d_002dCommon-problems">iESS(SAS)–Common problems</a>. <li><acronym>ESS[SAS]</acronym> mode for editing <acronym>SAS</acronym><!-- /@w --> language files works very well. See <a href="#ESS_0028SAS_0029_002d_002dEditing-files">ESS(SAS)–Editing files</a>. <li>There are two execution options for <acronym>SAS</acronym><!-- /@w --> on Windows. You can use batch. See <a href="#ESS_0028SAS_0029_002d_002dBatch-SAS-processes">ESS(SAS)–Batch SAS processes</a>. <p>Or you can mark regions with the mouse and submit the code with `submit-region' or paste them into <acronym>SAS</acronym><!-- /@w --> Display Manager. </ul> <!-- Local Variables: --> <!-- TeX-master: "ess.texi" --> <!-- End: --> <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS-for-BUGS"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS-for-JAGS">ESS for JAGS</a>, Previous: <a rel="previous" accesskey="p" href="#ESS-for-SAS">ESS for SAS</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">11 ESS for BUGS</h2> <ul class="menu"> <li><a accesskey="1" href="#ESS_0028BUGS_0029_002d_002dModel-files">ESS(BUGS)--Model files</a> <li><a accesskey="2" href="#ESS_0028BUGS_0029_002d_002dCommand-files">ESS(BUGS)--Command files</a> <li><a accesskey="3" href="#ESS_0028BUGS_0029_002d_002dLog-files">ESS(BUGS)--Log files</a> </ul> <p><acronym>ESS[BUGS]</acronym> was originally designed for use with BUGS software. Later, it evolved to support JAGS as a dialect of the BUGS language via <acronym>ESS[JAGS]</acronym>, however, <acronym>ESS[JAGS]</acronym> is documented in the section Help for JAGS. <acronym>ESS[BUGS]</acronym> 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, <acronym>ESS</acronym> creates templates for the command file from the model file so that a BUGS batch process can be defined by a single file. Third, <acronym>ESS</acronym> provides a BUGS batch script that allows <acronym>ESS</acronym> 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. <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(BUGS)--Model-files"></a> <a name="ESS_0028BUGS_0029_002d_002dModel-files"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS_0028BUGS_0029_002d_002dCommand-files">ESS(BUGS)--Command files</a>, Previous: <a rel="previous" accesskey="p" href="#ESS-for-BUGS">ESS for BUGS</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-BUGS">ESS for BUGS</a> </div> <h3 class="section">11.1 ESS[BUGS]–Model files</h3> <p>Model files with the <samp><span class="file">.bug</span></samp> extension are edited in <acronym>ESS[BUGS]</acronym> mode if <code>(require 'ess-bugs-d)</code> was performed or edited in <acronym>ESS[JAGS]</acronym> mode if <code>(require 'ess-jags-d)</code>. Three keys are bound for your use in <acronym>ESS[BUGS]</acronym>, <kbd>F2</kbd>, <kbd>C-c C-c</kbd> and <kbd>=</kbd>. <kbd>F2</kbd> performs the same action as it does in <acronym>ESS[SAS]</acronym>, See <a href="#ESS_0028SAS_0029_002d_002dFunction-keys-for-batch-processing">ESS(SAS)–Function keys for batch processing</a>. <kbd>C-c C-c</kbd> performs the function <code>ess-bugs-next-action</code> which you will use a lot. Pressing it in an empty buffer for a model file will produce a template for you. <kbd>=</kbd> inserts the set operator, <code><-</code>. <p><acronym>ESS[BUGS]</acronym> supports "replacement" variables. These variables are created as part of the template, i.e. with the first press of <kbd>C-c C-c</kbd> in an empty buffer. They are named by all capitals and start with <code>%</code>: <code>%N</code>, <code>%DATA</code>, <code>%INIT</code>, <code>%MONITOR</code> and <code>%STATS</code>. When you are finished editing your model file, pressing <kbd>C-c C-c</kbd> will perform the necessary replacements and build your command file for you. <p>The <code>%DATA</code> variable appears in the line <code>data in "%DATA";</code>. On the second press of <kbd>C-c C-c</kbd>, <code>%DATA</code> will be replaced by the model file name except it will have the <samp><span class="file">.dat</span></samp> extension. If your data file is named something else, then change <code>%DATA</code> in the template to the appropriate file name and no replacement will occur. <p>The <code>%INIT</code> variable appears in the line <code>inits in "%INIT";</code>. On the second press of <kbd>C-c C-c</kbd>, <code>%INIT</code> 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, <code>#</code>, at the beginning of the line. Or, if your init file is named something else, then change <code>%INIT</code> in the template to the appropriate file name. <p>The <code>%N</code> variable appears in the line <code>const N = 0;#%N</code>. Although it is commented, it is still active. Notice that later on in the template you have the line <code>for (i in 1:N)</code>. The BUGS constant <code>N</code> is the number of rows in your data file. When you press <kbd>C-c C-c</kbd>, the data file is read and the number of lines are counted (after <code>%DATA</code> is resolved, if necessary). The number of lines replace the zero in the <code>const N = 0;</code> statement. <p>The <code>%MONITOR</code> 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 <kbd>C-c C-c</kbd>, 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 <code>var</code> statement. <p>The <code>%STATS</code> variable is similar to the <code>%MONITOR</code> variable. It is a list of variables for which summary statistics will be calculated. When you press <kbd>C-c C-c</kbd>, the appropriate statements will be generated in your command file. <p>Please note that the <code>%DATA</code> and <code>%INIT</code> variables are only replaced on the second press of <kbd>C-c C-c</kbd>, but the actions for <code>%N</code>, <code>%MONITOR</code> and <code>%STATS</code> are performed on each press of <kbd>C-c C-c</kbd> if you re-visit the model file. <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(BUGS)--Command-files"></a> <a name="ESS_0028BUGS_0029_002d_002dCommand-files"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS_0028BUGS_0029_002d_002dLog-files">ESS(BUGS)--Log files</a>, Previous: <a rel="previous" accesskey="p" href="#ESS_0028BUGS_0029_002d_002dModel-files">ESS(BUGS)--Model files</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-BUGS">ESS for BUGS</a> </div> <h3 class="section">11.2 ESS[BUGS]–Command files</h3> <p>To avoid extension name collision, <samp><span class="file">.bmd</span></samp> is used for BUGS command files and <samp><span class="file">.jmd</span></samp> for JAGS command files. When you have finished editing your model file and press <kbd>C-c C-c</kbd>, a command file is created if one does not already exist. However, the command file was created, it recognizes two "replacement" variables: <code>%MONITOR</code> and <code>%STATS</code>. <p>Two <code>%MONITOR</code> 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 <code>%STATS</code> variable is similar. <p>When you are finished editing your command file, pressing <kbd>C-c C-c</kbd> again will submit your command file as a batch job. BUGS batch scripts are provided for both Unix and DOS in the <samp><span class="file">etc</span></samp> sub-directory of the <acronym>ESS</acronym> distribution. The Unix script is <samp><span class="file">backbugs</span></samp> for BUGS major version 0.6 and <samp><span class="file">backbug5</span></samp> for 0.5. The DOS script is <samp><span class="file">BACKBUGS.BAT</span></samp> for BUGS major version 0.6 only. These scripts allows <acronym>ESS</acronym> access to BUGS batch features that are not readily available with the batch scripts that come with BUGS. <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(BUGS)--Log-files"></a> <a name="ESS_0028BUGS_0029_002d_002dLog-files"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#ESS_0028BUGS_0029_002d_002dCommand-files">ESS(BUGS)--Command files</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-BUGS">ESS for BUGS</a> </div> <h3 class="section">11.3 ESS[BUGS]–Log files</h3> <p>To avoid extension name collision, <samp><span class="file">.bog</span></samp> is used for BUGS log files. The BUGS batch script provided with <acronym>ESS</acronym> creates the <samp><span class="file">.bog</span></samp> file from the <samp><span class="file">.log</span></samp> file when the batch process completes. If you need to look at the <samp><span class="file">.log</span></samp> file while the batch process is running, it will not appear in <acronym>ESS[BUGS]</acronym> mode. You may find <kbd>F2</kbd> useful to refresh the <samp><span class="file">.log</span></samp> if the batch process over-writes or appends it. <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS-for-JAGS"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Miscellaneous">Miscellaneous</a>, Previous: <a rel="previous" accesskey="p" href="#ESS-for-BUGS">ESS for BUGS</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">12 ESS for JAGS</h2> <ul class="menu"> <li><a accesskey="1" href="#ESS_0028JAGS_0029_002d_002dModel-files">ESS(JAGS)--Model files</a> <li><a accesskey="2" href="#ESS_0028JAGS_0029_002d_002dCommand-files">ESS(JAGS)--Command files</a> <li><a accesskey="3" href="#ESS_0028JAGS_0029_002d_002dLog-files">ESS(JAGS)--Log files</a> </ul> <p><acronym>ESS[BUGS]</acronym> was originally designed for use with BUGS software. Later, it evolved to support JAGS as a dialect of the BUGS language via <acronym>ESS[JAGS]</acronym>. Since BUGS and JAGS are quite similar, <acronym>ESS[BUGS]</acronym> and <acronym>ESS[JAGS]</acronym> are necessarily similar. <acronym>ESS[JAGS]</acronym> 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, <acronym>ESS</acronym> creates templates for the command file from the model file so that a JAGS batch process can be defined by a single file. Third, <acronym>ESS</acronym> provides a JAGS batch script that allows <acronym>ESS</acronym> to set JAGS batch parameters. Fourth, key sequences are defined to create a command file and submit a JAGS batch process. <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(JAGS)--Model-files"></a> <a name="ESS_0028JAGS_0029_002d_002dModel-files"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS_0028JAGS_0029_002d_002dCommand-files">ESS(JAGS)--Command files</a>, Previous: <a rel="previous" accesskey="p" href="#ESS-for-JAGS">ESS for JAGS</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-JAGS">ESS for JAGS</a> </div> <h3 class="section">12.1 ESS[JAGS]–Model files</h3> <p>Model files with the <samp><span class="file">.bug</span></samp> extension are edited in <acronym>ESS[BUGS]</acronym> mode if <code>(require 'ess-bugs-d)</code> was performed or edited in <acronym>ESS[JAGS]</acronym> mode if <code>(require 'ess-jags-d)</code>. Three keys are bound for your use in <acronym>ESS[BUGS]</acronym>, <kbd>F2</kbd>, <kbd>C-c C-c</kbd> and <kbd>=</kbd>. <kbd>F2</kbd> performs the same action as it does in <acronym>ESS[SAS]</acronym>, See <a href="#ESS_0028SAS_0029_002d_002dFunction-keys-for-batch-processing">ESS(SAS)–Function keys for batch processing</a>. <kbd>C-c C-c</kbd> performs the function <code>ess-bugs-next-action</code> which you will use a lot. Pressing it in an empty buffer for a model file will produce a template for you. <kbd>=</kbd> inserts the set operator, <code><-</code>. <p><acronym>ESS[JAGS]</acronym> does not support "replacement" variables which were part of <acronym>ESS[BUGS]</acronym>. 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 <acronym>ESS[JAGS]</acronym>: elisp local variables. These variables are created as part of the template, i.e. with the first press of <kbd>C-c C-c</kbd> in an empty buffer. For your <samp><span class="file">.bug</span></samp> file, they are named <code>ess-jags-chains</code>, <code>ess-jags-monitor</code>, <code>ess-jags-thin</code>, <code>ess-jags-burnin</code> and <code>ess-jags-update</code>; they appear in the <code>Local Variables</code> section. When you are finished editing your model file, pressing <kbd>C-c C-c</kbd> will perform the necessary actions to build your command file for you. <p>The <code>ess-jags-chains</code> variable is the number of chains that you want to initialize and sample from; defaults to 1. The <code>ess-jags-monitor</code> variable is a list of variables that you want monitored: encase each variable in double quotes. When you press <kbd>C-c C-c</kbd>, 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 <code>ess-jags-thin</code> variable is the thinning parameter. By default, the thinning parameter is set to 1, i.e. no thinning. The <code>ess-jags-burnin</code> variable is the number of initial samples to discard. By default, the burnin parameter is set to 10000. The <code>ess-jags-update</code> variable is the number of post-burnin samples to keep. By default, the update parameter is set to 10000. Both <code>ess-jags-burnin</code> and <code>ess-jags-update</code> are multiplied by <code>ess-jags-thin</code> since JAGS does not do it automatically. <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(JAGS)--Command-files"></a> <a name="ESS_0028JAGS_0029_002d_002dCommand-files"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#ESS_0028JAGS_0029_002d_002dLog-files">ESS(JAGS)--Log files</a>, Previous: <a rel="previous" accesskey="p" href="#ESS_0028JAGS_0029_002d_002dModel-files">ESS(JAGS)--Model files</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-JAGS">ESS for JAGS</a> </div> <h3 class="section">12.2 ESS[JAGS]–Command files</h3> <p>To avoid extension name collision, <samp><span class="file">.bmd</span></samp> is used for BUGS command files and <samp><span class="file">.jmd</span></samp> for JAGS command files. For your <samp><span class="file">.jmd</span></samp> file, there is only one variable, <code>ess-jags-command</code>, in the <code>Local Variables</code> section. When you have finished editing your model file and press <kbd>C-c C-c</kbd>, a command file is created if one does not already exist. When you are finished editing your command file, pressing <kbd>C-c C-c</kbd> again will submit your command file as a batch job. The <code>ess-jags-command</code> variable allows you to specify a different JAGS program to use to run your model; defaults to “jags”. <!-- node-name, next, previous, up --> <div class="node"> <a name="ESS(JAGS)--Log-files"></a> <a name="ESS_0028JAGS_0029_002d_002dLog-files"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#ESS_0028JAGS_0029_002d_002dCommand-files">ESS(JAGS)--Command files</a>, Up: <a rel="up" accesskey="u" href="#ESS-for-JAGS">ESS for JAGS</a> </div> <h3 class="section">12.3 ESS[JAGS]–Log files</h3> <p>The <samp><span class="file">.jog</span></samp> extension is used for JAGS log files. You may find <kbd>F2</kbd> useful to refresh the <samp><span class="file">.jog</span></samp> if the batch process over-writes or appends it. <!-- node-name, next, previous, up --> <div class="node"> <a name="Miscellaneous"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Mailing-lists_002fbug-reports">Mailing lists/bug reports</a>, Previous: <a rel="previous" accesskey="p" href="#ESS-for-JAGS">ESS for JAGS</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">13 Other features of ESS</h2> <p>ESS has a few miscellaneous features, which didn't fit anywhere else. <ul class="menu"> <li><a accesskey="1" href="#Highlighting">Highlighting</a>: Syntactic highlighting of buffers <li><a accesskey="2" href="#Parens">Parens</a>: Parenthesis matching <li><a accesskey="3" href="#Graphics">Graphics</a>: Using graphics with ESS <li><a accesskey="4" href="#Imenu">Imenu</a>: Support for Imenu in ESS <li><a accesskey="5" href="#Toolbar">Toolbar</a>: Support for toolbar in ESS <li><a accesskey="6" href="#TAGS">TAGS</a>: Using TAGS for S files <li><a accesskey="7" href="#Rdired">Rdired</a>: Directory editor for R objects <li><a accesskey="8" href="#Rutils">Rutils</a>: R object/package management and help utilities <li><a accesskey="9" href="#Org">Org</a>: Interaction with Org mode <li><a href="#Sweave-and-AUCTeX">Sweave and AUCTeX</a>: Support for Sweave in ESS and AUCTeX <li><a href="#Debugging-R">Debugging R</a>: Debugging R code in ESS </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Highlighting"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Parens">Parens</a>, Previous: <a rel="previous" accesskey="p" href="#Miscellaneous">Miscellaneous</a>, Up: <a rel="up" accesskey="u" href="#Miscellaneous">Miscellaneous</a> </div> <h3 class="section">13.1 Syntactic highlighting of buffers</h3> <p>ESS provides Font-Lock (see <a href="emacs.html#Faces">Using Multiple Typefaces</a>) patterns for Inferior S Mode, S Mode, and S Transcript Mode buffers. <a name="index-Font_002dlock-mode-210"></a><a name="index-highlighting-211"></a> Syntax highlighting within ESS buffers is controlled by the variable <code>ess-font-lock-mode</code>, which by default is true. Input to inferior ESS processes is also highlighted syntactically if <code>inferior-ess-font-lock-input</code> 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. <!-- To activate highlighting, you need to turn on Font Lock mode in the --> <!-- appropriate buffers. This can be done on a per-buffer basis with --> <!-- @kbd{M-x font-lock-mode}, or may be done by adding --> <!-- @code{turn-on-font-lock} to @code{inferior-ess-mode-hook}, --> <!-- @code{ess-mode-hook} and @code{ess-transcript-mode-hook}. Your systems --> <!-- administrator may have done this for you in @file{ess-site.el} --> <!-- (@pxref{Customization}). --> <p>The font-lock patterns are defined in the following variables, which you may modify if desired: <div class="defun"> — Variable: <b>inferior-ess-R-font-lock-keywords</b><var><a name="index-inferior_002dess_002dR_002dfont_002dlock_002dkeywords-212"></a></var><br> <blockquote><p>Font-lock patterns for inferior *R* processes. (There is a corresponding <code>inferior-ess-S-font-lock-keywords</code> for *S* processes.) The default value highlights prompts, inputs, assignments, output messages, vector and matrix labels, and literals such as ‘<samp><span class="samp">NA</span></samp>’ and <code>TRUE</code>. </p></blockquote></div> <div class="defun"> — Variable: <b>ess-R-mode-font-lock-keywords</b><var><a name="index-ess_002dR_002dmode_002dfont_002dlock_002dkeywords-213"></a></var><br> <blockquote><p>Font-lock patterns for ESS R programming mode. (There is a corresponding <code>ess-S-mode-font-lock-keywords</code> for S buffers.) The default value highlights function names, literals, assignments, source functions and reserved words. </p></blockquote></div> <!-- 2007-11-08 - this var no longer exists. --> <!-- @defvar ess-trans-font-lock-keywords --> <!-- Font-lock patterns for ESS Transcript Mode. The default value --> <!-- highlights the same patterns as in Inferior ESS Mode. --> <!-- @end defvar --> <!-- node-name, next, previous, up --> <div class="node"> <a name="Parens"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Graphics">Graphics</a>, Previous: <a rel="previous" accesskey="p" href="#Highlighting">Highlighting</a>, Up: <a rel="up" accesskey="u" href="#Miscellaneous">Miscellaneous</a> </div> <h3 class="section">13.2 Parenthesis matching</h3> <p>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: <pre class="example"> (paren-set-mode 'paren) ;for XEmacs (show-paren-mode t) ;for Emacs </pre> <!-- node-name, next, previous, up --> <div class="node"> <a name="Graphics"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Imenu">Imenu</a>, Previous: <a rel="previous" accesskey="p" href="#Parens">Parens</a>, Up: <a rel="up" accesskey="u" href="#Miscellaneous">Miscellaneous</a> </div> <h3 class="section">13.3 Using graphics with ESS</h3> <p><a name="index-graphics-214"></a>One of the main features of the <code>S</code> package is its ability to generate high-resolution graphics plots, and ESS provides a number of features for dealing with such plots. <ul class="menu"> <li><a accesskey="1" href="#printer">printer</a>: The printer() graphics driver <li><a accesskey="2" href="#X11">X11</a>: The X11() (and other X-windows based) driver <li><a accesskey="3" href="#winjava">winjava</a>: Java Graphics Device </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="printer"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#X11">X11</a>, Previous: <a rel="previous" accesskey="p" href="#Graphics">Graphics</a>, Up: <a rel="up" accesskey="u" href="#Graphics">Graphics</a> </div> <h4 class="subsection">13.3.1 Using ESS with the <code>printer()</code> driver</h4> <p>This is the simplest (and least desirable) method of using graphics within ESS. S's <code>printer()</code> 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 <pre class="example"> printer(width=79) </pre> <p><a name="index-printer_0028_0029-215"></a>(the <code>width=79</code> 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 <code>show()</code> command is issued, which displays the current figure. <!-- node-name, next, previous, up --> <div class="node"> <a name="X11"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#winjava">winjava</a>, Previous: <a rel="previous" accesskey="p" href="#printer">printer</a>, Up: <a rel="up" accesskey="u" href="#Graphics">Graphics</a> </div> <h4 class="subsection">13.3.2 Using ESS with windowing devices</h4> <p><a name="index-X-windows-216"></a>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 <code>ess-ask-about-display</code> <a name="index-ess_002dask_002dabout_002ddisplay-217"></a>is non-<code>nil</code>. <!-- node-name, next, previous, up --> <div class="node"> <a name="winjava"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#X11">X11</a>, Up: <a rel="up" accesskey="u" href="#Graphics">Graphics</a> </div> <h4 class="subsection">13.3.3 Java Graphics Device</h4> <p><a name="index-winjava-218"></a> S+6.1 and newer on Windows contains a java library that supports graphics. Send the commands: <pre class="example"> library(winjava) java.graph() </pre> <p class="noindent">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.) <!-- node-name, next, previous, up --> <div class="node"> <a name="Imenu"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Toolbar">Toolbar</a>, Previous: <a rel="previous" accesskey="p" href="#Graphics">Graphics</a>, Up: <a rel="up" accesskey="u" href="#Miscellaneous">Miscellaneous</a> </div> <h3 class="section">13.4 Imenu</h3> <p>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). <p>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 <code>imenu-generic-expression</code>. This value is set by various ESS variables such as <code>ess-imenu-S-generic-expression</code>. <!-- node-name, next, previous, up --> <div class="node"> <a name="Toolbar"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#TAGS">TAGS</a>, Previous: <a rel="previous" accesskey="p" href="#Imenu">Imenu</a>, Up: <a rel="up" accesskey="u" href="#Miscellaneous">Miscellaneous</a> </div> <h3 class="section">13.5 Toolbar</h3> <p>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 <a href="#Customization">Customization</a>, for ways to change the toolbar. <!-- node-name, next, previous, up --> <div class="node"> <a name="TAGS"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Rdired">Rdired</a>, Previous: <a rel="previous" accesskey="p" href="#Toolbar">Toolbar</a>, Up: <a rel="up" accesskey="u" href="#Miscellaneous">Miscellaneous</a> </div> <h3 class="section">13.6 TAGS</h3> <p>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. <p>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. <pre class="example"> etags --language=none --regex='/\([^ \t]+\)[ \t]*<-[ \t]*function/\1/' *.R </pre> <p>This will find entries in your source file of the form: <pre class="example"> some.name <- function </pre> <p>with the function name starting in column 0. Windows users may need to change the single quotes to double quotes. <p>R version 2.9.0 introduced a front-end script for finding R tags, which calls the ‘<samp><span class="samp">rtags()</span></samp>’ 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: <pre class="example"> R CMD rtags --help </pre> <p>For further details, see <a href="http://developer.r-project.org/rtags.html">http://developer.r-project.org/rtags.html</a> <!-- node-name, next, previous, up --> <div class="node"> <a name="Rdired"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Rutils">Rutils</a>, Previous: <a rel="previous" accesskey="p" href="#TAGS">TAGS</a>, Up: <a rel="up" accesskey="u" href="#Miscellaneous">Miscellaneous</a> </div> <h3 class="section">13.7 Rdired</h3> <p>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. <p>To get started, first make sure you can load ess-rdired. Add the following to your .emacs and then restart emacs. <pre class="example"> (autoload 'ess-rdired "ess-rdired" "View *R* objects in a dired-like buffer." t) </pre> <p>Start an R session with <kbd>M-x R</kbd> and then store a few variables, such as: <pre class="example"> s <- sin(seq(from=0, to=8*pi, length=100)) x <- c(1, 4, 9) y <- rnorm(20) z <- TRUE </pre> <p>Then use <kbd>M-x ess-rdired</kbd> to create a buffer listing the objects in your current environment and display it in a new window: <pre class="example"> mode length s numeric 100 x numeric 3 y numeric 20 z logical 1 </pre> <p>Type <kbd>C-h m</kbd> or <kbd>?</kbd> 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). <!-- node-name, next, previous, up --> <div class="node"> <a name="Rutils"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Org">Org</a>, Previous: <a rel="previous" accesskey="p" href="#Rdired">Rdired</a>, Up: <a rel="up" accesskey="u" href="#Miscellaneous">Miscellaneous</a> </div> <h3 class="section">13.8 Rutils</h3> <p>Ess-rutils builds up on ess-rdired, providing key bindings for performing basic R functions in the inferior-ESS process buffer, such as loading and managing packages, object manipulation (listing, viewing, and deleting), and alternatives to <code>help.start()</code> and <code>RSiteSearch()</code> that use the <samp><span class="command">browse-url</span></samp> Emacs function. The library can be loaded using <kbd>M-x load-file</kbd>, but the easiest is to include: <pre class="lisp"> (require 'ess-rutils) </pre> <p>in your .emacs. Once R is started with <kbd>M-x R</kbd>, and if the value of the customizable variable <code>ess-rutils-keys</code> is true, several key bindings become available in iESS process buffers: <ul> <li><kbd>C-c C-. l</kbd> (<samp><span class="command">ess-rutils-local-pkgs</span></samp>) <br> <a name="index-ess_002drutils_002dlocalpkgs-219"></a>List all packages in all available libraries. <li><kbd>C-c C-. r</kbd> (<samp><span class="command">ess-rutils-repos-pkgs</span></samp>) <br> <a name="index-ess_002drutils_002drepospkgs-220"></a>List available packages from repositories listed by <samp><span class="command">getOptions(``repos'')</span></samp> in the current R session. <li><kbd>C-c C-. u</kbd> (<samp><span class="command">ess-rutils-update-pkgs</span></samp>) <br> <a name="index-ess_002drutils_002dupdatepkgs-221"></a>Update packages in a particular library and repository. <li><kbd>C-c C-. a</kbd> (<samp><span class="command">ess-rutils-apropos</span></samp>) <br> <a name="index-ess_002drutils_002dapropos-222"></a>Search for a string using apropos. <li><kbd>C-c C-. m</kbd> (<samp><span class="command">ess-rutils-rm-all</span></samp>) <br> <a name="index-ess_002drutils_002drmall-223"></a>Remove all R objects. <li><kbd>C-c C-. o</kbd> (<samp><span class="command">ess-rutils-objs</span></samp>) <br> <a name="index-ess_002drutils_002dobjs-224"></a>Manipulate R objects; wrapper for <samp><span class="command">ess-rdired</span></samp>. <li><kbd>C-c C-. w</kbd> (<samp><span class="command">ess-rutils-load-wkspc</span></samp>) <br> <a name="index-ess_002drutils_002dloadwkspc-225"></a>Load a workspace file into R. <li><kbd>C-c C-. s</kbd> (<samp><span class="command">ess-rutils-save-wkspc</span></samp>) <br> <a name="index-ess_002drutils_002dsavewkspc-226"></a>Save a workspace file. <li><kbd>C-c C-. d</kbd> (<samp><span class="command">ess-change-directory</span></samp>) <br> <a name="index-ess_002dchange_002ddirectory-227"></a>Change the working directory for the current R session. <li><kbd>C-c C-. H</kbd> (<samp><span class="command">ess-rutils-html-docs</span></samp>) <br> <a name="index-ess_002drutils_002dhtmldocs-228"></a>Use <samp><span class="command">browse-url</span></samp> to navigate R html documentation. </ul> <p>See the submenu ‘<samp><span class="samp">Rutils</span></samp>’ under the iESS menu for alternative access to these functions. The function <samp><span class="command">ess-rutils-rsitesearch</span></samp> is provided without a particular key binding. This function is useful in any Emacs buffer, so can be bound to a user-defined key: <pre class="lisp"> (eval-after-load "ess-rutils" '(global-set-key [(control c) (f6)] 'ess-rutils-rsitesearch)) </pre> <p><a name="index-ess_002drutils_002drsitesearch-229"></a> Functions for listing objects and packages (<samp><span class="command">ess-rutils-local-pkgs</span></samp>, <samp><span class="command">ess-rutils-repos-pkgs</span></samp>, and <samp><span class="command">ess-rutils-objs</span></samp>) show results in a separate buffer and window, in <code>ess-rutils-mode</code>, providing useful key bindings in this mode (type <kbd>?</kbd> in this buffer for a description). <!-- node-name, next, previous, up --> <div class="node"> <a name="Org"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Sweave-and-AUCTeX">Sweave and AUCTeX</a>, Previous: <a rel="previous" accesskey="p" href="#Rutils">Rutils</a>, Up: <a rel="up" accesskey="u" href="#Miscellaneous">Miscellaneous</a> </div> <h3 class="section">13.9 Interaction with Org mode</h3> <p>Org-mode (<a href="http://orgmode.org">http://orgmode.org</a>) now supports reproducible research and literate programming in many languages (including R) – see chapter 14 of the Org manual (<a href="http://orgmode.org/org.html#Working-With-Source-Code">http://orgmode.org/org.html#Working-With-Source-Code</a>). For ESS users, this offers a document-based work environment within which to embed ESS usage. R code lives in code blocks of an Org document, from which it can be edited in ess-mode, evaluated, extracted ("tangled") to pure code files. The code can also be exported ("woven") with the surrounding text to several formats including HTML and LaTeX. Results of evaluation including figures can be captured in the Org document, and data can be passed from the Org document (e.g. from a table) to the ESS R process. (This section contributed by Dan Davison and Eric Schulte.) <!-- node-name, next, previous, up --> <div class="node"> <a name="Sweave-and-AUCTeX"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Debugging-R">Debugging R</a>, Previous: <a rel="previous" accesskey="p" href="#Org">Org</a>, Up: <a rel="up" accesskey="u" href="#Miscellaneous">Miscellaneous</a> </div> <h3 class="section">13.10 Support for Sweave in ESS and AUCTeX</h3> <p>ESS provides support for writing and processing Sweave (<a href="http://www.statistik.lmu.de/~leisch/Sweave">http://www.statistik.lmu.de/~leisch/Sweave</a>), building up on Emacs' noweb-mode for literate programming. When working on an Sweave document, the following key bindings are available: <ul> <li><kbd>M-n s</kbd> (<samp><span class="command">ess-swv-weave</span></samp>) <br> <a name="index-ess_002dswv_002dweave-230"></a>Run Sweave on the current .Rnw file. <li><kbd>M-n l</kbd> (<samp><span class="command">ess-swv-latex</span></samp>) <br> <a name="index-ess_002dswv_002dlatex-231"></a>Run LaTeX after Sweave'ing. <li><kbd>M-n p</kbd> (<samp><span class="command">ess-swv-PS</span></samp>) <br> <a name="index-ess_002dswv_002dPS-232"></a>Generate and display a postscript file after LaTeX'ing. <li><kbd>M-n P</kbd> (<samp><span class="command">ess-swv-PDF</span></samp>) <br> <a name="index-ess_002dswv_002dPDF-233"></a>Generate and display a PDF file after LaTeX'ing. The command used to generate the PDF file is the first element of <code>ess-swv-pdflatex-commands</code>. </ul> <p>Sweave'ing with <code>ess-swv-weave</code> starts an inferior-ESS process, if one is not available. Other commands are available from the ‘<samp><span class="samp">Sweaving, Tangling, ...</span></samp>’ submenu of the Noweb menu. <p>AUCTeX (<a href="http://www.gnu.org/software/auctex">http://www.gnu.org/software/auctex</a>) users may prefer to set the variable <code>ess-swv-plug-into-AUCTeX-p</code> (available from the “ESS Sweave” customization group) to t. Alternatively, the same can be achieved by activating the entry “AUCTeX Interface” from the ‘<samp><span class="samp">Sweaving, Tangling, ...</span></samp>’ submenu, which toggles this variable on or off. When the interface is activated, new entries for Sweave'ing and LaTeX'ing thereafter are available from AUCTeX's “Command” menu. Sweave'ing can, thus, be done by <kbd>C-c C-c Sweave RET</kbd> without an inferior-ESS process. Similarly, LaTeX'ing can be done by <kbd>C-c C-c LaTeXSweave RET</kbd>. In both cases, the process can be monitored with <kbd>C-c C-l</kbd> (<code>TeX-recenter-output-buffer</code>). Open the viewer with <kbd>C-c C-v</kbd> (<code>TeX-view</code>), as usual in AUCTeX. <!-- node-name, next, previous, up --> <div class="node"> <a name="Debugging-R"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#Sweave-and-AUCTeX">Sweave and AUCTeX</a>, Up: <a rel="up" accesskey="u" href="#Miscellaneous">Miscellaneous</a> </div> <h3 class="section">13.11 Debugging R code in ESS</h3> <p>There are currently two extra facilities that have been developed for debugging R code within ESS. <ul> <li>“Ess-tracebug is a package for interactive visual debugging of R code from ESS. It provides visual debugging, browser, recover and conditional breakpoints; watch window and loggers; interactive debug/undebug of R functions and methods at point; highlighting and easy error navigation and interactive traceback.” <a href="http://code.google.com/p/ess-tracebug/">http://code.google.com/p/ess-tracebug/</a> <li>The R package edtdbg “integrates R's debugging facilities with your text editor, featuring code tracking, variable display, quick breakpoint setting, and easy toggling of function debug status.” It provides support for both Emacs and VIM. Package available from CRAN mirrors. </ul> <!-- node-name, next, previous, up@chapter Using S4 --> <div class="node"> <a name="Mailing-lists%2fbug-reports"></a> <a name="Mailing-lists_002fbug-reports"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Customization">Customization</a>, Previous: <a rel="previous" accesskey="p" href="#Miscellaneous">Miscellaneous</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="chapter">14 Bugs and Bug Reporting, Mailing Lists</h2> <ul class="menu"> <li><a accesskey="1" href="#Bugs">Bugs</a> <li><a accesskey="2" href="#Reporting-Bugs">Reporting Bugs</a> <li><a accesskey="3" href="#Mailing-Lists">Mailing Lists</a> <li><a accesskey="4" href="#Help-with-emacs">Help with emacs</a> </ul> <div class="node"> <a name="Bugs"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Reporting-Bugs">Reporting Bugs</a>, Previous: <a rel="previous" accesskey="p" href="#Mailing-lists_002fbug-reports">Mailing lists/bug reports</a>, Up: <a rel="up" accesskey="u" href="#Mailing-lists_002fbug-reports">Mailing lists/bug reports</a> </div> <h3 class="section">14.1 Bugs</h3> <p><a name="index-bugs-234"></a> <ul> <li>Commands like <code>ess-display-help-on-object</code> 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. <li>The <code>ess-eval-</code> 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 <em>windows</em> with <code>window-point</code> at the right place. <li>It's possible to clear the modification flag (say, by saving the buffer) with the edit buffer not having been loaded into S. <li>Backup files can sometimes be left behind, even when <code>ess-keep-dump-files</code> is <code>nil</code>. <li>Passing an incomplete S expression to <code>ess-execute</code> causes ESS to hang. <li>The function-based commands don't always work as expected on functions whose body is not a parenthesized or compound expression, and don't even recognize anonymous functions (i.e. functions not assigned to any variable). <li>Multi-line commands could be handled better by the command history mechanism. <li>Changes to the continutation prompt in R (e.g. <code>options(continue = " ")</code>) 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 <code>inferior-ess-secondary-prompt</code> in <code>R-customize-alist</code>. </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Reporting-Bugs"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Mailing-Lists">Mailing Lists</a>, Previous: <a rel="previous" accesskey="p" href="#Bugs">Bugs</a>, Up: <a rel="up" accesskey="u" href="#Mailing-lists_002fbug-reports">Mailing lists/bug reports</a> </div> <h3 class="section">14.2 Reporting Bugs</h3> <p><a name="index-Bug-reports-235"></a><a name="index-ess_002dsubmit_002dbug_002dreport-236"></a> <p>Please send bug reports, suggestions etc. to <a href="mailto:ESS-bugs@stat.math.ethz.ch">ESS-bugs@stat.math.ethz.ch</a> <p>The easiest way to do this is within Emacs by typing <p><kbd>M-x ess-submit-bug-report</kbd> <p>This also gives the maintainers valuable information about your installation which may help us to identify or even fix the bug. <p>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. <p>Note that comments, suggestions, words of praise and large cash donations are also more than welcome. <!-- node-name, next, previous, up --> <div class="node"> <a name="Mailing-Lists"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Help-with-emacs">Help with emacs</a>, Previous: <a rel="previous" accesskey="p" href="#Reporting-Bugs">Reporting Bugs</a>, Up: <a rel="up" accesskey="u" href="#Mailing-lists_002fbug-reports">Mailing lists/bug reports</a> </div> <h3 class="section">14.3 Mailing Lists</h3> <p>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 <a href="mailto:ess-help-request@stat.math.ethz.ch">ess-help-request@stat.math.ethz.ch</a>; contributions to the list may be mailed to <a href="mailto:ess-help@stat.math.ethz.ch">ess-help@stat.math.ethz.ch</a>. Rest assured, this is a fairly low-volume mailing list. <p>The purposes of the mailing list include <ul> <li> helping users of ESS to get along with it. <li> discussing aspects of using ESS on Emacs and XEmacs. <li> suggestions for improvements. <li> announcements of new releases of ESS. <li> posting small patches to ESS. </ul> <!-- node-name, next, previous, up --> <div class="node"> <a name="Help-with-emacs"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#Mailing-Lists">Mailing Lists</a>, Up: <a rel="up" accesskey="u" href="#Mailing-lists_002fbug-reports">Mailing lists/bug reports</a> </div> <h3 class="section">14.4 Help with emacs</h3> <p>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 <kbd>M-x xemacs-www-faq</kbd> or <kbd>M-x view-emacs-FAQ</kbd>) and EmacsWiki (<a href="http://www.emacswiki.org">http://www.emacswiki.org</a>). Please consult them before asking on the mailing list about issues that are not specific to ESS. <!-- _not_yet_ @node Help OS, Installation, Help for Statistical Packages, Top --> <!-- _not_yet_ @comment node-name, next, previous, up --> <!-- _not_yet_ @chapter Help, arranged by Operating System --> <!-- _not_yet_ --> <!-- _not_yet_ @menu --> <!-- _not_yet_ * Unix installation:: --> <!-- _not_yet_ * Microsoft Windows installation:: --> <!-- _not_yet_ * System dependent:: Other variables you may need to change --> <!-- _not_yet_ @end menu --> <!-- node-name, next, previous, up --> <div class="node"> <a name="Customization"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Key-Index">Key Index</a>, Previous: <a rel="previous" accesskey="p" href="#Mailing-lists_002fbug-reports">Mailing lists/bug reports</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="appendix">Appendix A Customizing ESS</h2> <p><a name="index-customization-237"></a> ESS can be easily customized to your taste simply by including the appropriate lines in your <samp><span class="file">.emacs</span></samp> 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. <p>Most of these variables can be viewed and set using the Custom facility within Emacs. Type <kbd>M-x customize-group RET ess RET</kbd> to see all the ESS variables that can be customized. Variables are grouped by subject to make it easy to find related variables. <!-- Stephen deleted incomplete variable list Wed 25 Aug 2004. --> <div class="node"> <a name="Key-Index"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Concept-Index">Concept Index</a>, Previous: <a rel="previous" accesskey="p" href="#Customization">Customization</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="unnumbered">Key (Character) Index</h2> <!-- @node Command Index, Concept Index, Key Index, Top --> <!-- @unnumbered Command and Function Index --> <!-- @printindex fn --> <!-- node-name, next, previous, up --> <div class="node"> <a name="Concept-Index"></a> <p><hr> Next: <a rel="next" accesskey="n" href="#Variable-and-command-index">Variable and command index</a>, Previous: <a rel="previous" accesskey="p" href="#Key-Index">Key Index</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="unnumbered">Concept Index</h2> <div class="node"> <a name="Variable-and-command-index"></a> <p><hr> Previous: <a rel="previous" accesskey="p" href="#Concept-Index">Concept Index</a>, Up: <a rel="up" accesskey="u" href="#Top">Top</a> </div> <h2 class="unnumbered">Variable and command index</h2> <div class="footnote"> <hr> <a name="texinfo-footnotes-in-document"></a><h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> The variable <code>ess-change-sp-regexp</code> 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 <code>attach</code>, <code>detach</code>, <code>collection</code> or <code>library</code>) which modify the search list.</p> <hr></div> </body></html>