The R Project SVN R

Rev

Rev 26795 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

<html lang="en">
<head>
<title>R FAQ</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="description" content="R FAQ">
<meta name="generator" content="makeinfo 4.6">
<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 }
--></style>
</head>
<body>
<h1 class="settitle">R FAQ</h1>
<div class="node">
<p><hr>
Node:&nbsp;<a name="Top">Top</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Introduction">Introduction</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#dir">(dir)</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
<br>
</div>

<h2 class="unnumbered">R FAQ</h2>

<h2>Frequently Asked Questions on R</h2>
<h2>Version 1.8-12, 2003-10-31</h2>
<h2>ISBN 3-900051-01-1</h2>
<address>Kurt Hornik</address>
<p><p><hr><p>

<ul class="menu">
<li><a accesskey="1" href="#Introduction">Introduction</a>: 
<li><a accesskey="2" href="#R%20Basics">R Basics</a>: 
<li><a accesskey="3" href="#R%20and%20S">R and S</a>: 
<li><a accesskey="4" href="#R%20Web%20Interfaces">R Web Interfaces</a>: 
<li><a accesskey="5" href="#R%20Add-On%20Packages">R Add-On Packages</a>: 
<li><a accesskey="6" href="#R%20and%20Emacs">R and Emacs</a>: 
<li><a accesskey="7" href="#R%20Miscellanea">R Miscellanea</a>: 
<li><a accesskey="8" href="#R%20Programming">R Programming</a>: 
<li><a accesskey="9" href="#R%20Bugs">R Bugs</a>: 
<li><a href="#Acknowledgments">Acknowledgments</a>: 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Introduction">Introduction</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#R%20Basics">R Basics</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Top">Top</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>
<br>
</div>

<h2 class="chapter">1 Introduction</h2>

<p>This document contains answers to some of the most frequently asked
questions about R.

<ul class="menu">
<li><a accesskey="1" href="#Legalese">Legalese</a>: 
<li><a accesskey="2" href="#Obtaining%20this%20document">Obtaining this document</a>: 
<li><a accesskey="3" href="#Citing%20this%20document">Citing this document</a>: 
<li><a accesskey="4" href="#Notation">Notation</a>: 
<li><a accesskey="5" href="#Feedback">Feedback</a>: 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Legalese">Legalese</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Obtaining%20this%20document">Obtaining this document</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Introduction">Introduction</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>
<br>
</div>

<h3 class="section">1.1 Legalese</h3>

<p>This document is copyright &copy; 1998-2003 by Kurt
Hornik.

   <p>This document is free software; you can redistribute it and/or modify it
under the terms of the <small>GNU</small> General Public License as published
by the Free Software Foundation; either version 2, or (at your option)
any later version.

   <p>This document is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
<small>GNU</small> General Public License for more details.

   <p>A copy of the <small>GNU</small> General Public License is available via WWW
at

<pre class="display">     <a href="http://www.gnu.org/copyleft/gpl.html">http://www.gnu.org/copyleft/gpl.html</a>.
     </pre>

<p>You can also obtain it by writing to the Free Software Foundation, Inc.,
59 Temple Place -- Suite 330, Boston, MA 02111-1307, USA.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Obtaining%20this%20document">Obtaining this document</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Citing%20this%20document">Citing this document</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Legalese">Legalese</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>
<br>
</div>

<h3 class="section">1.2 Obtaining this document</h3>

<p>The latest version of this document is always available from

<pre class="display">     <a href="http://www.ci.tuwien.ac.at/~hornik/R/">http://www.ci.tuwien.ac.at/~hornik/R/</a>
     </pre>

   <p>From there, you can obtain versions converted to
<a href="http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.txt">plain <small>ASCII</small> text</a>,
<a href="http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.dvi.gz">DVI</a>,
<a href="http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.info.gz"><small>GNU</small> info</a>, <a href="http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html"><small>HTML</small></a>,
<a href="http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.pdf">PDF</a>,
<a href="http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.ps.gz">PostScript</a> as
well as the <a href="http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.texi">Texinfo source</a> used for creating all these formats using the
<a href="http://texinfo.org/"><small>GNU</small> Texinfo system</a>.

   <p>You can also obtain the R <small>FAQ</small> from the <code>doc/FAQ</code>
subdirectory of a <small>CRAN</small> site (see <a href="#What%20is%20CRAN%3f">What is CRAN?</a>).

<div class="node">
<p><hr>
Node:&nbsp;<a name="Citing%20this%20document">Citing this document</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Notation">Notation</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Obtaining%20this%20document">Obtaining this document</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>
<br>
</div>

<h3 class="section">1.3 Citing this document</h3>

<p>In publications, please refer to this <small>FAQ</small> as Hornik
(2003), "The R <small>FAQ</small>", and give the above,
<em>official</em> <small>URL</small> and the ISBN 3-900051-01-1.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Notation">Notation</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Feedback">Feedback</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Citing%20this%20document">Citing this document</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>
<br>
</div>

<h3 class="section">1.4 Notation</h3>

<p>Everything should be pretty standard.  <code>R&gt;</code> is used for the R
prompt, and a <code>$</code> for the shell prompt (where applicable).

<div class="node">
<p><hr>
Node:&nbsp;<a name="Feedback">Feedback</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Notation">Notation</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Introduction">Introduction</a>
<br>
</div>

<h3 class="section">1.5 Feedback</h3>

<p>Feedback is of course most welcome.

   <p>In particular, note that I do not have access to Windows or Macintosh
systems.  Features specific to the Windows and MacOS X ports of R are
described in the <a href="http://www.stats.ox.ac.uk/pub/R/rw-FAQ.html">"R for Windows <small>FAQ</small>"</a> and the
<a href="http://cran.r-project.org/bin/macosx/RAqua-FAQ.html">"R for Macintosh <small>FAQ</small>/DOC"</a>.  If you have information on Macintosh or
Windows systems that you think should be added to this document, please
let me know.

<div class="node">
<p><hr>
Node:&nbsp;<a name="R%20Basics">R Basics</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#R%20and%20S">R and S</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Introduction">Introduction</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>
<br>
</div>

<h2 class="chapter">2 R Basics</h2>

<ul class="menu">
<li><a accesskey="1" href="#What%20is%20R%3f">What is R?</a>: 
<li><a accesskey="2" href="#What%20machines%20does%20R%20run%20on%3f">What machines does R run on?</a>: 
<li><a accesskey="3" href="#What%20is%20the%20current%20version%20of%20R%3f">What is the current version of R?</a>: 
<li><a accesskey="4" href="#How%20can%20R%20be%20obtained%3f">How can R be obtained?</a>: 
<li><a accesskey="5" href="#How%20can%20R%20be%20installed%3f">How can R be installed?</a>: 
<li><a accesskey="6" href="#Are%20there%20Unix%20binaries%20for%20R%3f">Are there Unix binaries for R?</a>: 
<li><a accesskey="7" href="#What%20documentation%20exists%20for%20R%3f">What documentation exists for R?</a>: 
<li><a accesskey="8" href="#Citing%20R">Citing R</a>: 
<li><a accesskey="9" href="#What%20mailing%20lists%20exist%20for%20R%3f">What mailing lists exist for R?</a>: 
<li><a href="#What%20is%20CRAN%3f">What is CRAN?</a>: 
<li><a href="#Can%20I%20use%20R%20for%20commercial%20purposes%3f">Can I use R for commercial purposes?</a>: 
<li><a href="#Why%20is%20R%20named%20R%3f">Why is R named R?</a>: 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20is%20R%3f">What is R?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#What%20machines%20does%20R%20run%20on%3f">What machines does R run on?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20Basics">R Basics</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Basics">R Basics</a>
<br>
</div>

<h3 class="section">2.1 What is R?</h3>

<p>R is a system for statistical computation and graphics.  It consists of
a language plus a run-time environment with graphics, a debugger, access
to certain system functions, and the ability to run programs stored in
script files.

   <p>The design of R has been heavily influenced by two existing languages:
Becker, Chambers &amp; Wilks' S (see <a href="#What%20is%20S%3f">What is S?</a>) and Sussman's
<a href="http://www.cs.indiana.edu/scheme-repository/home.html">Scheme</a>. 
Whereas the resulting language is very similar in appearance to S, the
underlying implementation and semantics are derived from Scheme. 
See <a href="#What%20are%20the%20differences%20between%20R%20and%20S%3f">What are the differences between R and S?</a>, for further details.

   <p>The core of R is an interpreted computer language which allows branching
and looping as well as modular programming using functions.  Most of the
user-visible functions in R are written in R.  It is possible for the
user to interface to procedures written in the C, C++, or FORTRAN
languages for efficiency.  The R distribution contains functionality for
a large number of statistical procedures.  Among these are: linear and
generalized linear models, nonlinear regression models, time series
analysis, classical parametric and nonparametric tests, clustering and
smoothing.  There is also a large set of functions which provide a
flexible graphical environment for creating various kinds of data
presentations.  Additional modules ("add-on packages") are available
for a variety of specific purposes (see <a href="#R%20Add-On%20Packages">R Add-On Packages</a>).

   <p>R was initially written by <a href="mailto:Ross.Ihaka@R-project.org">Ross Ihaka</a>
and <a href="mailto:Robert.Gentleman@R-project.org">Robert Gentleman</a> at the
Department of Statistics of the University of Auckland in Auckland, New
Zealand.  In addition, a large group of individuals has contributed to R
by sending code and bug reports.

   <p>Since mid-1997 there has been a core group (the "R Core Team") who can
modify the R source code CVS archive.  The group currently consists of
Doug Bates, John Chambers, Peter Dalgaard, Robert Gentleman, Kurt
Hornik, Stefano Iacus, Ross Ihaka, Friedrich Leisch, Thomas Lumley,
Martin Maechler, Duncan Murdoch, Paul Murrell, Martyn Plummer, Brian
Ripley, Duncan Temple Lang, and Luke Tierney.

   <p>R has a home page at <a href="http://www.R-project.org/">http://www.R-project.org/</a>.  It is free
software distributed under a <small>GNU</small>-style copyleft, and an
official part of the <small>GNU</small> project ("<small>GNU</small> S").

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20machines%20does%20R%20run%20on%3f">What machines does R run on?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#What%20is%20the%20current%20version%20of%20R%3f">What is the current version of R?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20is%20R%3f">What is R?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Basics">R Basics</a>
<br>
</div>

<h3 class="section">2.2 What machines does R run on?</h3>

<p>R is being developed for the Unix, Windows and Mac families of operating
systems.  Support for Mac OS Classic will end with the 1.7 series.

   <p>The current version of R will configure and build under a number of
common Unix platforms including i386-freebsd, <var>cpu</var>-linux-gnu for
the i386, alpha, arm, hppa, ia64, m68k, powerpc, and sparc CPUs (see
e.g. <a href="http://buildd.debian.org/build.php?&amp;pkg=r-base">http://buildd.debian.org/build.php?&amp;pkg=r-base</a>),
i386-sun-solaris, powerpc-apple-darwin, mips-sgi-irix, alpha-dec-osf4,
rs6000-ibm-aix, hppa-hp-hpux, and sparc-sun-solaris.

   <p>If you know about other platforms, please drop us a note.

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20is%20the%20current%20version%20of%20R%3f">What is the current version of R?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20R%20be%20obtained%3f">How can R be obtained?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20machines%20does%20R%20run%20on%3f">What machines does R run on?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Basics">R Basics</a>
<br>
</div>

<h3 class="section">2.3 What is the current version of R?</h3>

<p>The current released version is 1.8.0.  Based on this
`major.minor.patchlevel' numbering scheme, there are two development
versions of R, working towards the next patch (`r-patched') and minor or
eventually major (`r-devel') releases of R, respectively.  Version
r-patched is for bug fixes mostly.  New features are typically
introduced in r-devel.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20R%20be%20obtained%3f">How can R be obtained?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20R%20be%20installed%3f">How can R be installed?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20is%20the%20current%20version%20of%20R%3f">What is the current version of R?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Basics">R Basics</a>
<br>
</div>

<h3 class="section">2.4 How can R be obtained?</h3>

<p>Sources, binaries and documentation for R can be obtained via <small>CRAN</small>,
the "Comprehensive R Archive Network" (see <a href="#What%20is%20CRAN%3f">What is CRAN?</a>).

   <p>Sources are also available via anonymous rsync.  Use

<pre class="example">     rsync -rC --delete rsync.R-project.org::<var>module</var> R
     </pre>

<p>to create a copy of the source tree specified by <var>module</var> in the
subdirectory <code>R</code> of the current directory, where <var>module</var>
specifies one of the three existing flavors of the R sources, and can be
one of <code>r-release</code> (current released version), <code>r-patched</code>
(patched released version), and <code>r-devel</code> (development version). 
The rsync trees are created directly from the master CVS archive and are
updated hourly.  The <code>-C</code> and in the <code>rsync</code> command
is to cause it to skip the CVS directories.  Further information on
<code>rsync</code> is available at <a href="http://rsync.samba.org/rsync/">http://rsync.samba.org/rsync/</a>.

   <p>The sources of the development version are also available via anonymous
CVS.  See <a href="http://anoncvs.R-project.org">http://anoncvs.R-project.org</a> for more information.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20R%20be%20installed%3f">How can R be installed?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Are%20there%20Unix%20binaries%20for%20R%3f">Are there Unix binaries for R?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20R%20be%20obtained%3f">How can R be obtained?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Basics">R Basics</a>
<br>
</div>

<h3 class="section">2.5 How can R be installed?</h3>

<ul class="menu">
<li><a accesskey="1" href="#How%20can%20R%20be%20installed%20(Unix)">How can R be installed (Unix)</a>: 
<li><a accesskey="2" href="#How%20can%20R%20be%20installed%20(Windows)">How can R be installed (Windows)</a>: 
<li><a accesskey="3" href="#How%20can%20R%20be%20installed%20(Macintosh)">How can R be installed (Macintosh)</a>: 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20R%20be%20installed%20(Unix)">How can R be installed (Unix)</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20R%20be%20installed%20(Windows)">How can R be installed (Windows)</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20R%20be%20installed%3f">How can R be installed?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#How%20can%20R%20be%20installed%3f">How can R be installed?</a>
<br>
</div>

<h3 class="subsection">2.5.1 How can R be installed (Unix)</h4>

<p>If binaries are available for your platform (see <a href="#Are%20there%20Unix%20binaries%20for%20R%3f">Are there Unix binaries for R?</a>), you can use these, following the instructions that
come with them.

   <p>Otherwise, you can compile and install R yourself, which can be done
very easily under a number of common Unix platforms (see <a href="#What%20machines%20does%20R%20run%20on%3f">What machines does R run on?</a>).  The file <code>INSTALL</code> that comes with the
R distribution contains a brief introduction, and the "R Installation
and Administration" guide (see <a href="#What%20documentation%20exists%20for%20R%3f">What documentation exists for R?</a>)
has full details.

   <p>Note that you need a FORTRAN compiler or <code>f2c</code> in addition to
a C compiler to build R.  Also, you need Perl version 5 to build the R
object documentations.  (If this is not available on your system, you
can obtain a PDF version of the object reference manual via <small>CRAN</small>.)

   <p>In the simplest case, untar the R source code, change to the directory
thus created, and issue the following commands (at the shell prompt):

<pre class="example">     $ ./configure
     $ make
     </pre>

   <p>If these commands execute successfully, the R binary and a shell script
front-end called <code>R</code> are created and copied to the <code>bin</code>
directory.  You can copy the script to a place where users can invoke
it, for example to <code>/usr/local/bin</code>.  In addition, plain text help
pages as well as <small>HTML</small> and LaTeX versions of the documentation are
built.

   <p>Use <kbd>make dvi</kbd> to create DVI versions of the R manuals, such as
<code>refman.dvi</code> (an R object reference index) and <code>R-exts.dvi</code>,
the "R Extension Writers Guide", in the <code>doc/manual</code>
subdirectory.  These files can be previewed and printed using standard
programs such as <code>xdvi</code> and <code>dvips</code>.  You can also use
<kbd>make pdf</kbd> to build PDF (Portable Document Format) version of the
manuals, and view these using e.g. Acrobat.  Manuals written in the
<small>GNU</small> Texinfo system can also be converted to info files
suitable for reading online with Emacs or stand-alone <small>GNU</small>
Info; use <kbd>make info</kbd> to create these versions (note that this
requires <code>makeinfo</code> version 4).

   <p>Finally, use <kbd>make check</kbd> to find out whether your R system works
correctly.

   <p>You can also perform a "system-wide" installation using <kbd>make
install</kbd>.  By default, this will install to the following directories:

     <dl>
<dt><code>${prefix}/bin</code>
     <dd>the front-end shell script
<br><dt><code>${prefix}/man/man1</code>
     <dd>the man page
<br><dt><code>${prefix}/lib/R</code>
     <dd>all the rest (libraries, on-line help system, <small class="dots">...</small>).  This is the "R
Home Directory" (<code>R_HOME</code>) of the installed system. 
</dl>

<p>In the above, <code>prefix</code> is determined during configuration
(typically <code>/usr/local</code>) and can be set by running
<code>configure</code> with the option

<pre class="example">     $ ./configure --prefix=/where/you/want/R/to/go
     </pre>

<p>(E.g., the R executable will then be installed into
<code>/where/you/want/R/to/go/bin</code>.)

   <p>To install DVI, info and PDF versions of the manuals, use <kbd>make
install-dvi</kbd>, <kbd>make install-info</kbd> and <kbd>make install-pdf</kbd>,
respectively.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20R%20be%20installed%20(Windows)">How can R be installed (Windows)</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20R%20be%20installed%20(Macintosh)">How can R be installed (Macintosh)</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20R%20be%20installed%20(Unix)">How can R be installed (Unix)</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#How%20can%20R%20be%20installed%3f">How can R be installed?</a>
<br>
</div>

<h3 class="subsection">2.5.2 How can R be installed (Windows)</h4>

<p>The <code>bin/windows</code> directory of a <small>CRAN</small> site contains binaries for
a base distribution and a large number of add-on packages from <small>CRAN</small>
to run on Windows 95, 98, ME, NT4, 2000, and XP (at least) on Intel and
clones (but not on other platforms).  The Windows version of R was
created by Robert Gentleman, and is now being developed and maintained
by <a href="mailto:murdoch@stats.uwo.ca">Duncan Murdoch</a> and
<a href="mailto:Brian.Ripley@R-project.org">Brian D. Ripley</a>.

   <p>For most installations the Windows installer program will be the easiest
tool to use.

   <p>See the <a href="http://www.stats.ox.ac.uk/pub/R/rw-FAQ.html">"R for Windows <small>FAQ</small>"</a> for more details.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20R%20be%20installed%20(Macintosh)">How can R be installed (Macintosh)</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20R%20be%20installed%20(Windows)">How can R be installed (Windows)</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#How%20can%20R%20be%20installed%3f">How can R be installed?</a>
<br>
</div>

<h3 class="subsection">2.5.3 How can R be installed (Macintosh)</h4>

<p>The <code>bin/macosx</code> directory of a <small>CRAN</small> site contains a standard
Apple installer package named <code>RAqua.pkg.sit</code> compressed in Aladdin
Stuffit format.  Once downloaded, uncompressed and executed, the
installer will install the current non-developer release of R.  RAqua is
a native MacOSX Darwin version of R with an Aqua GUI.  Inside
<code>bin/macosx/</code><var>x</var><code>.</code><var>y</var><code></code> there are prebuilt binary packages to
be used with RAqua corresponding to the "<var>x</var>.<var>y</var>" release of
R. The installation of these packages is available through the
"Package" menu of the RAqua GUI.  This port of R for MacOSX is
maintained by <a href="mailto:Stefano.Iacus@R-project.org">Stefano Iacus</a>.  The
<a href="http://cran.r-project.org/bin/macosx/RAqua-FAQ.html">"R for Macintosh <small>FAQ</small>/DOC"</a> has more details.

   <p>The <code>bin/macos</code> directory of a <small>CRAN</small> site contains bin-hexed
(<code>hqx</code>) and stuffit (<code>sit</code>) archives for a base distribution
and a large number of add-on packages of R 1.7.1 to run under MacOS 8.6
to MacOS 9.2.2.  This port of R for Macintosh is no longer supported.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Are%20there%20Unix%20binaries%20for%20R%3f">Are there Unix binaries for R?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#What%20documentation%20exists%20for%20R%3f">What documentation exists for R?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20R%20be%20installed%3f">How can R be installed?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Basics">R Basics</a>
<br>
</div>

<h3 class="section">2.6 Are there Unix binaries for R?</h3>

<p>The <code>bin/linux</code> directory of a <small>CRAN</small> site contains Debian
stable/testing packages for the i386 platform (now part of the Debian
distribution and maintained by Dirk Eddelbuettel), Mandrake 9.0/9.1 i386
packages by Michele Alzetta, Red Hat 7.x/8.x/9 i386 packages by Martyn
Plummer, SuSE 7.3/8.0/8.1/8.2 i386 packages by Detlef Steuer, and
VineLinux 2.6 i386 packages by Susunu Tanimura.

   <p>The Debian packages can be accessed through APT, the Debian package
maintenance tool.  Simply add the line

<pre class="example">     deb http://cran.R-project.org/bin/linux/debian <var>distribution</var> main
     </pre>

<p>(where <var>distribution</var> is either <code>stable</code> or <code>testing</code>;
feel free to use a <small>CRAN</small> mirror instead of the master) to the file
<code>/etc/apt/sources.list</code>.  Once you have added that line the
programs <code>apt-get</code>, <code>apt-cache</code>, and <code>dselect</code>
(using the apt access method) will automatically detect and install
updates of the R packages.

   <p>No other binary distributions are currently publically available.

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20documentation%20exists%20for%20R%3f">What documentation exists for R?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Citing%20R">Citing R</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Are%20there%20Unix%20binaries%20for%20R%3f">Are there Unix binaries for R?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Basics">R Basics</a>
<br>
</div>

<h3 class="section">2.7 What documentation exists for R?</h3>

<p>Online documentation for most of the functions and variables in R
exists, and can be printed on-screen by typing <kbd>help(</kbd><var>name</var><kbd>)</kbd>
(or <kbd>?</kbd><var>name</var><kbd></kbd>) at the R prompt, where <var>name</var> is the name of
the topic help is sought for.  (In the case of unary and binary
operators and control-flow special forms, the name may need to be be
quoted.)

   <p>This documentation can also be made available as one reference manual
for on-line reading in <small>HTML</small> and PDF formats, and as hardcopy via
LaTeX, see <a href="#How%20can%20R%20be%20installed%3f">How can R be installed?</a>.  An up-to-date <small>HTML</small>
version is always available for web browsing at
<a href="http://stat.ethz.ch/R-manual/">http://stat.ethz.ch/R-manual/</a>.

   <p>The R distribution also comes with the following manuals.

     <ul>
<li>"An Introduction to R" (<code>R-intro</code>)
includes information on data types, programming elements, statistical
modeling and graphics.  This document is based on the "Notes on
<small>S-PLUS</small>" by Bill Venables and David Smith. 
<li>"Writing R Extensions" (<code>R-exts</code>)
currently describes the process of creating R add-on packages, writing R
documentation, R's system and foreign language interfaces, and the R
<small>API</small>. 
<li>"R Data Import/Export" (<code>R-data</code>)
is a guide to importing and exporting data to and from R. 
<li>"The R Language Definition" (<code>R-lang</code>),
a first version of the "Kernighan &amp; Ritchie of R", explains
evaluation, parsing, object oriented programming, computing on the
language, and so forth. 
<li>"R Installation and Administration" (<code>R-admin</code>). 
</ul>

   <p>Books on R include

   <blockquote>
Peter Dalgaard (2002), "Introductory Statistics with R", Springer: New
York, ISBN 0-387-95475-9.

        <p>J. Fox (2002), "An R and <small>S-PLUS</small> Companion to Applied Regression",
Sage Publications, ISBN 0-761-92280-6 (softcover) or 0-761-92279-2
(hardcover), <a href="http://www.socsci.mcmaster.ca/jfox/Books/Companion/">http://www.socsci.mcmaster.ca/jfox/Books/Companion/</a>.

        <p>J. Maindonald and J. Braun (2003), "Data Analysis and Graphics Using
R", Cambridge University Press, ISBN 0-521-81336-0.

        <p>S. M. Iacus and G. Masarotto (2002), "Laboratorio di statistica con R
", McGraw-Hill, ISBN 88-386-6084-0 (in Italian). 
</blockquote>

<p>The book

   <blockquote>
W. N. Venables and B. D. Ripley (2002), "Modern Applied Statistics with
S.  Fourth Edition".  Springer, ISBN 0-387-95457-0
</blockquote>

<p>has a home page at <a href="http://www.stats.ox.ac.uk/pub/MASS4/">http://www.stats.ox.ac.uk/pub/MASS4/</a> providing
additional material.  Its companion is

   <blockquote>
W. N. Venables and B. D. Ripley (2000), "S Programming".  Springer,
ISBN 0-387-98966-8
</blockquote>

<p>and provides an in-depth guide to writing software in the S language
which forms the basis of both the commercial <small>S-PLUS</small> and the Open
Source R data analysis software systems.  See
<a href="http://www.stats.ox.ac.uk/pub/MASS3/Sprog/">http://www.stats.ox.ac.uk/pub/MASS3/Sprog/</a> for more information.

   <p>In addition to material written specifically or explicitly for R,
documentation for S/<small>S-PLUS</small> (see <a href="#R%20and%20S">R and S</a>) can be used in
combination with this <small>FAQ</small> (see <a href="#What%20are%20the%20differences%20between%20R%20and%20S%3f">What are the differences between R and S?</a>).  Introductory books include

   <blockquote>
P. Spector (1994), "An introduction to S and <small>S-PLUS</small>", Duxbury Press.

        <p>A. Krause and M. Olsen (2002), "The Basics of <small>S-PLUS</small>" (Third
Edition).  Springer, ISBN 0-387-95456-2
</blockquote>

   <p>The book

   <blockquote>
J. C. Pinheiro and D. M. Bates (2000), "Mixed-Effects Models in S and
<small>S-PLUS</small>", Springer, ISBN 0-387-98957-0
</blockquote>

<p>provides a comprehensive guide to the use of the <strong>nlme</strong> package
for linear and nonlinear mixed-effects models.  This has a home page at
<a href="http://nlme.stat.wisc.edu/MEMSS/">http://nlme.stat.wisc.edu/MEMSS/</a>.

   <p>As an example of how R can be used in teaching an advanced introductory
statistics course, see

   <blockquote>
D. Nolan and T. Speed (2000), "Stat Labs: Mathematical Statistics
Through Applications", Springer Texts in Statistics, ISBN
0-387-98974-9
</blockquote>

<p>This integrates theory of statistics with the practice of statistics
through a collection of case studies ("labs"), and uses R to analyze
the data.  More information can be found at
<a href="http://www.stat.Berkeley.EDU/users/statlabs/">http://www.stat.Berkeley.EDU/users/statlabs/</a>.

   <p>Last, but not least, Ross' and Robert's experience in designing and
implementing R is described in Ihaka &amp; Gentleman (1996), "R: A Language
for Data Analysis and Graphics",
<a href="http://www.amstat.org/publications/jcgs/"><em>Journal of Computational and Graphical Statistics</em></a>, <strong>5</strong>, 299-314.

   <p>An annotated bibliography (BibTeX format) of R-related publications
which includes most of the above references can be found at

<pre class="display">     <a href="http://www.R-project.org/doc/bib/R.bib">http://www.R-project.org/doc/bib/R.bib</a>
     </pre>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Citing%20R">Citing R</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#What%20mailing%20lists%20exist%20for%20R%3f">What mailing lists exist for R?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20documentation%20exists%20for%20R%3f">What documentation exists for R?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Basics">R Basics</a>
<br>
</div>

<h3 class="section">2.8 Citing R</h3>

<p>To cite R in publications, use

<pre class="example">     @Manual{,
       title        = {R: A language and environment for statistical
                       computing},
       author       = {{R Development Core Team}},
       organization = {R Foundation for Statistical Computing},
       address      = {Vienna, Austria},
       year         = 2003,
       note         = {ISBN 3-900051-00-3},
       url          = {http://www.R-project.org}
     }
     </pre>

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20mailing%20lists%20exist%20for%20R%3f">What mailing lists exist for R?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#What%20is%20CRAN%3f">What is CRAN?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Citing%20R">Citing R</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Basics">R Basics</a>
<br>
</div>

<h3 class="section">2.9 What mailing lists exist for R?</h3>

<p>Thanks to <a href="mailto:Martin.Maechler@R-project.org">Martin Maechler</a>, there
are four mailing lists devoted to R.

     <dl>
<dt><code>R-announce</code>
     <dd>A moderated list for announcements about the development of R and the
availability of new code. 
<br><dt><code>R-packages</code>
     <dd>A moderated list for announcements on the availability of new or
enhanced contributed packages. 
<br><dt><code>R-help</code>
     <dd>The `main' R mailing list, for discussion about problems and solutions
using R, announcements (not covered by `R-announce' and `R-packages')
about the development of R and the availability of new code,
enhancements and patches to the source code and documentation of R,
comparison and compatibility with S and <small>S-PLUS</small>, and for the posting of
nice examples and benchmarks. 
<br><dt><code>R-devel</code>
     <dd>This list is for discussions about the future of R and pre-testing of
new versions.  It is meant for those who maintain an active position in
the development of R. 
</dl>

<p>Note that the R-announce and R-packages lists are gatewayed into R-help. 
Hence, you should subscribe to either of them only in case you are not
subscribed to R-help.

   <p>Send email to <a href="mailto:R-help@lists.R-project.org">R-help@lists.R-project.org</a> to reach everyone on
the R-help mailing list.  To subscribe (or unsubscribe) to this list
send <code>subscribe</code> (or <code>unsubscribe</code>) in the <em>body</em> of the
message (not in the subject!) to
<a href="mailto:R-help-request@lists.R-project.org">R-help-request@lists.R-project.org</a>.  Information about the list
can be obtained by sending an email with <code>info</code> as its contents to
<a href="mailto:R-help-request@lists.R-project.org">R-help-request@lists.R-project.org</a>.

   <p>Subscription and posting to the other lists is done analogously, with
<code>R-help</code> replaced by <code>R-announce</code>, <code>R-packages</code>, and
<code>R-devel</code>, respectively.

   <p>Subscriptions to the R-help and R-devel mailing lists are also available
in digest (plain or MIME) format, see the <code>doc/html/mail.html</code> file
in <small>CRAN</small> for more information.

   <p>It is recommended that you send mail to R-help rather than only to the R
Core developers (who are also subscribed to the list, of course).  This
may save them precious time they can use for constantly improving R, and
will typically also result in much quicker feedback for yourself.

   <p>Of course, in the case of bug reports it would be very helpful to have
code which reliably reproduces the problem.  Also, make sure that you
include information on the system and version of R being used.  See
<a href="#R%20Bugs">R Bugs</a> for more details.

   <p>Archives of the above three mailing lists are made available on the net
in a monthly schedule via the <code>doc/html/mail.html</code> file in <small>CRAN</small>. 
Searchable archives of the lists are available via
<a href="http://maths.newcastle.edu.au/~rking/R/">http://maths.newcastle.edu.au/~rking/R/</a>.

   <p>The R Core Team can be reached at <a href="mailto:R-core@lists.R-project.org">R-core@lists.R-project.org</a>
for comments and reports.

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20is%20CRAN%3f">What is CRAN?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Can%20I%20use%20R%20for%20commercial%20purposes%3f">Can I use R for commercial purposes?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20mailing%20lists%20exist%20for%20R%3f">What mailing lists exist for R?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Basics">R Basics</a>
<br>
</div>

<h3 class="section">2.10 What is <small>CRAN</small>?</h3>

<p>The "Comprehensive R Archive Network" (<small>CRAN</small>) is a collection of
sites which carry identical material, consisting of the R
distribution(s), the contributed extensions, documentation for R, and
binaries.

   <p>The <small>CRAN</small> master site at TU Wien, Austria, can be found at the
<small>URL</small>

   <blockquote>
<a href="http://cran.R-project.org/">http://cran.R-project.org/</a>
</blockquote>

<p>and is currently being mirrored daily at

   <blockquote>
        <p><table><tr align="left"><td valign="top"><a href="http://cran.at.R-project.org/">http://cran.at.R-project.org/</a>
</td><td valign="top">(TU Wien, Austria)
<br></td></tr><tr align="left"><td valign="top"><a href="http://cran.au.R-project.org/">http://cran.au.R-project.org/</a>
</td><td valign="top">(PlanetMirror, Australia)
<br></td></tr><tr align="left"><td valign="top"><a href="http://cran.br.R-project.org/">http://cran.br.R-project.org/</a>
</td><td valign="top">(Universidade Federal de Paran&aacute;, Brazil)
<br></td></tr><tr align="left"><td valign="top"><a href="http://cran.ch.R-project.org/">http://cran.ch.R-project.org/</a>
</td><td valign="top">(ETH Z&uuml;rich, Switzerland)
<br></td></tr><tr align="left"><td valign="top"><a href="http://cran.de.R-project.org/">http://cran.de.R-project.org/</a>
</td><td valign="top">(APP, Germany)
<br></td></tr><tr align="left"><td valign="top"><a href="http://cran.dk.R-project.org/">http://cran.dk.R-project.org/</a>
</td><td valign="top">(SunSITE, Denmark)
<br></td></tr><tr align="left"><td valign="top"><a href="http://cran.es.R-project.org/">http://cran.es.R-project.org/</a>
</td><td valign="top">(Spanish National Research Network, Madrid, Spain)
<br></td></tr><tr align="left"><td valign="top"><a href="http://cran.hu.R-project.org/">http://cran.hu.R-project.org/</a>
</td><td valign="top">(Semmelweis U, Hungary)
<br></td></tr><tr align="left"><td valign="top"><a href="http://cran.uk.R-project.org/">http://cran.uk.R-project.org/</a>
</td><td valign="top">(U of Bristol, United Kingdom)
<br></td></tr><tr align="left"><td valign="top"><a href="http://cran.us.R-project.org/">http://cran.us.R-project.org/</a>
</td><td valign="top">(U of Wisconsin, USA)
<br></td></tr><tr align="left"><td valign="top"><a href="http://cran.za.R-project.org/">http://cran.za.R-project.org/</a>
</td><td valign="top">(Rhodes U, South Africa)
        <br></td></tr></table>
</blockquote>

<p>Please use the <small>CRAN</small> site closest to you to reduce network load.

   <p>From <small>CRAN</small>, you can obtain the latest official release of R, daily
snapshots of R (copies of the current CVS trees), as gzipped and bzipped
tar files, a wealth of additional contributed code, as well as prebuilt
binaries for various operating systems (Linux, MacOS Classic, MacOS X,
and MS Windows).  <small>CRAN</small> also provides access to documentation on R,
existing mailing lists and the R Bug Tracking system.

   <p>To "submit" to <small>CRAN</small>, simply upload to
<a href="ftp://cran.R-project.org/incoming/">ftp://cran.R-project.org/incoming/</a> and send an email to
<a href="mailto:cran@R-project.org">cran@R-project.org</a>.  Note that <small>CRAN</small> generally does not
accept submissions of precompiled binaries due to security reasons.

   <blockquote>
<strong>Note:</strong>  It is very important that you indicate the copyright
(license) information (<small>GPL</small>, <small>BSD</small>, Artistic, <small class="dots">...</small>)
in your submission. 
</blockquote>

   <p>Please always use the <small>URL</small> of the master site when referring to
<small>CRAN</small>.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Can%20I%20use%20R%20for%20commercial%20purposes%3f">Can I use R for commercial purposes?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Why%20is%20R%20named%20R%3f">Why is R named R?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20is%20CRAN%3f">What is CRAN?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Basics">R Basics</a>
<br>
</div>

<h3 class="section">2.11 Can I use R for commercial purposes?</h3>

<p>R is released under the <a href="http://www.gnu.org/copyleft/gpl.html">GNU General Public License (GPL)</a>.  If you have any questions regarding the
legality of using R in any particular situation you should bring it up
with your legal counsel.  We are in no position to offer legal advice.

   <p>It is the opinion of the R Core Team that one can use R for commercial
purposes (e.g., in business or in consulting).  The GPL, like all Open
Source licenses, permits all and any use of the package.  It only
restricts distribution of R or of other programs containing code from R. 
This is made clear in clause 6 ("No Discrimination Against Fields of
Endeavor") of the <a href="http://www.opensource.org/docs/definition.html">Open Source Definition</a>:

   <blockquote>
The license must not restrict anyone from making use of the program in a
specific field of endeavor.  For example, it may not restrict the
program from being used in a business, or from being used for genetic
research. 
</blockquote>

<p>It is also explicitly stated in clause 0 of the GPL, which says in part

   <blockquote>
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of running
the Program is not restricted, and the output from the Program is
covered only if its contents constitute a work based on the Program. 
</blockquote>

   <p>Most add-on packages, including all recommended ones, also explicitly
allow commercial use in this way.  A few packages are restricted to
"non-commercial use"; you should contact the author to clarify whether
these may be used or seek the advice of your legal counsel.

   <p>None of the discussion in this section constitutes legal advice.  The R
Core Team does not provide legal advice under any circumstances.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Why%20is%20R%20named%20R%3f">Why is R named R?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Can%20I%20use%20R%20for%20commercial%20purposes%3f">Can I use R for commercial purposes?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Basics">R Basics</a>
<br>
</div>

<h3 class="section">2.12 Why is R named R?</h3>

<p>The name is partly based on the (first) names of the first two R authors
(Robert Gentleman and Ross Ihaka), and partly a play on the name of the
Bell Labs language `S' (see <a href="#What%20is%20S%3f">What is S?</a>).

<div class="node">
<p><hr>
Node:&nbsp;<a name="R%20and%20S">R and S</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#R%20Web%20Interfaces">R Web Interfaces</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20Basics">R Basics</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>
<br>
</div>

<h2 class="chapter">3 R and S</h2>

<ul class="menu">
<li><a accesskey="1" href="#What%20is%20S%3f">What is S?</a>: 
<li><a accesskey="2" href="#What%20is%20S-PLUS%3f">What is S-PLUS?</a>: 
<li><a accesskey="3" href="#What%20are%20the%20differences%20between%20R%20and%20S%3f">What are the differences between R and S?</a>: 
<li><a accesskey="4" href="#Is%20there%20anything%20R%20can%20do%20that%20S-PLUS%20cannot%3f">Is there anything R can do that S-PLUS cannot?</a>: 
<li><a accesskey="5" href="#What%20is%20R-plus%3f">What is R-plus?</a>: 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20is%20S%3f">What is S?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#What%20is%20S-PLUS%3f">What is S-PLUS?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20and%20S">R and S</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20and%20S">R and S</a>
<br>
</div>

<h3 class="section">3.1 What is S?</h3>

<p>S is a very high level language and an environment for data analysis and
graphics.  In 1998, the Association for Computing Machinery
(<small>ACM</small>) presented its Software System Award to John M. Chambers,
the principal designer of S, for

   <blockquote>
the S system, which has forever altered the way people analyze,
visualize, and manipulate data <small class="dots">...</small>

        <p>S is an elegant, widely accepted, and enduring software system, with
conceptual integrity, thanks to the insight, taste, and effort of John
Chambers. 
</blockquote>

   <p>The evolution of the S language is characterized by four books by John
Chambers and coauthors, which are also the primary references for S.

     <ul>
<li>Richard A. Becker and John M. Chambers (1984), "S.  An Interactive
Environment for Data Analysis and Graphics," Monterey: Wadsworth and
Brooks/Cole.

     <p>This is also referred to as the "<em>Brown Book</em>", and of historical
interest only.

     </p><li>Richard A. Becker, John M. Chambers and Allan R. Wilks (1988), "The New
S Language," London: Chapman &amp; Hall.

     <p>This book is often called the "<em>Blue Book</em>", and introduced what
is now known as S version 2.

     </p><li>John M. Chambers and Trevor J. Hastie (1992), "Statistical Models in
S,"  London: Chapman &amp; Hall.

     <p>This is also called the "<em>White Book</em>", and introduced S version
3, which added structures to facilitate statistical modeling in S.

     </p><li>John M. Chambers (1998), "Programming with Data," New York: Springer,
ISBN 0-387-98503-4
(&lt;<code>http://cm.bell-labs.com/cm/ms/departments/sia/Sbook/</code>&gt;).

     <p>This "<em>Green Book</em>" describes version 4 of S, a major revision of
S designed by John Chambers to improve its usefulness at every stage of
the programming process. 
</ul>

   <p>See <a href="http://cm.bell-labs.com/cm/ms/departments/sia/S/history.html">http://cm.bell-labs.com/cm/ms/departments/sia/S/history.html</a>
for further information on "Stages in the Evolution of S".

   <p>There is a huge amount of user-contributed code for S, available at the
<a href="http://lib.stat.cmu.edu/S/">S Repository</a> at <small>CMU</small>.

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20is%20S-PLUS%3f">What is S-PLUS?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#What%20are%20the%20differences%20between%20R%20and%20S%3f">What are the differences between R and S?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20is%20S%3f">What is S?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20and%20S">R and S</a>
<br>
</div>

<h3 class="section">3.2 What is <small>S-PLUS</small>?</h3>

<p><small>S-PLUS</small> is a value-added version of S sold by Insightful Corporation. 
Based on the S language, <small>S-PLUS</small> provides functionality in a wide
variety of areas, including robust regression, modern non-parametric
regression, time series, survival analysis, multivariate analysis,
classical statistical tests, quality control, and graphics drivers. 
Add-on modules add additional capabilities for wavelet analysis, spatial
statistics, GARCH models, and design of experiments.

   <p>See the <a href="http://www.insightful.com/products/splus/">Insightful <small>S-PLUS</small> page</a> for further information.

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20are%20the%20differences%20between%20R%20and%20S%3f">What are the differences between R and S?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Is%20there%20anything%20R%20can%20do%20that%20S-PLUS%20cannot%3f">Is there anything R can do that S-PLUS cannot?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20is%20S-PLUS%3f">What is S-PLUS?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20and%20S">R and S</a>
<br>
</div>

<h3 class="section">3.3 What are the differences between R and S?</h3>

<p>We can regard S as a language with three current implementations or
"engines", the "old S engine" (S version 3; <small>S-PLUS</small> 3.x and 4.x),
the "new S engine" (S version 4; <small>S-PLUS</small> 5.x and above), and R. 
Given this understanding, asking for "the differences between R and S"
really amounts to asking for the specifics of the R implementation of
the S language, i.e., the difference between the R and S <em>engines</em>.

   <p>For the remainder of this section, "S" refers to the S engines and not
the S language.

<ul class="menu">
<li><a accesskey="1" href="#Lexical%20scoping">Lexical scoping</a>: 
<li><a accesskey="2" href="#Models">Models</a>: 
<li><a accesskey="3" href="#Others">Others</a>: 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Lexical%20scoping">Lexical scoping</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Models">Models</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20are%20the%20differences%20between%20R%20and%20S%3f">What are the differences between R and S?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#What%20are%20the%20differences%20between%20R%20and%20S%3f">What are the differences between R and S?</a>
<br>
</div>

<h3 class="subsection">3.3.1 Lexical scoping</h4>

<p>Contrary to other implementations of the S language, R has adopted the
evaluation model of Scheme.

   <p>This difference becomes manifest when <em>free</em> variables occur in a
function.  Free variables are those which are neither formal parameters
(occurring in the argument list of the function) nor local variables
(created by assigning to them in the body of the function).  Whereas S
(like C) by default uses <em>static</em> scoping, R (like Scheme) has
adopted <em>lexical</em> scoping.  This means the values of free variables
are determined by a set of global variables in S, but in R by the
bindings that were in effect at the time the function was created.

   <p>Consider the following function:

<pre class="example">     cube &lt;- function(n) {
       sq &lt;- function() n * n
       n * sq()
     }
     </pre>

   <p>Under S, <code>sq()</code> does not "know" about the variable <code>n</code>
unless it is defined globally:

<pre class="example">     S&gt; cube(2)
     Error in sq():  Object "n" not found
     Dumped
     S&gt; n &lt;- 3
     S&gt; cube(2)
     [1] 18
     </pre>

   <p>In R, the "environment" created when <code>cube()</code> was invoked is
also looked in:

<pre class="example">     R&gt; cube(2)
     [1] 8
     </pre>

   <p>As a more "interesting" real-world problem, suppose you want to write
a function which returns the density function of the r-th order
statistic from a sample of size n from a (continuous)
distribution.  For simplicity, we shall use both the cdf and pdf of the
distribution as explicit arguments.  (Example compiled from various
postings by Luke Tierney.)

   <p>The <small>S-PLUS</small> documentation for <code>call()</code> basically suggests the
following:

<pre class="example">     dorder &lt;- function(n, r, pfun, dfun) {
       f &lt;- function(x) NULL
       con &lt;- round(exp(lgamma(n + 1) - lgamma(r) - lgamma(n - r + 1)))
       PF &lt;- call(substitute(pfun), as.name("x"))
       DF &lt;- call(substitute(dfun), as.name("x"))
       f[[length(f)]] &lt;-
         call("*", con,
              call("*", call("^", PF, r - 1),
                   call("*", call("^", call("-", 1, PF), n - r),
                        DF)))
       f
     }
     </pre>

<p>Rather tricky, isn't it?  The code uses the fact that in S,
functions are just lists of special mode with the function body as the
last argument, and hence does not work in R (one could make the idea
work, though).

   <p>A version which makes heavy use of <code>substitute()</code> and seems to work
under both S and R is

<pre class="example">     dorder &lt;- function(n, r, pfun, dfun) {
       con &lt;- round(exp(lgamma(n + 1) - lgamma(r) - lgamma(n - r + 1)))
       eval(substitute(function(x) K * PF(x)^a * (1 - PF(x))^b * DF(x),
                       list(PF = substitute(pfun), DF = substitute(dfun),
                            a = r - 1, b = n - r, K = con)))
     }
     </pre>

<p>(the <code>eval()</code> is not needed in S).

   <p>However, in R there is a much easier solution:

<pre class="example">     dorder &lt;- function(n, r, pfun, dfun) {
       con &lt;- round(exp(lgamma(n + 1) - lgamma(r) - lgamma(n - r + 1)))
       function(x) {
         con * pfun(x)^(r - 1) * (1 - pfun(x))^(n - r) * dfun(x)
       }
     }
     </pre>

<p>This seems to be the "natural" implementation, and it works because
the free variables in the returned function can be looked up in the
defining environment (this is lexical scope).

   <p>Note that what you really need is the function <em>closure</em>, i.e., the
body along with all variable bindings needed for evaluating it.  Since
in the above version, the free variables in the value function are not
modified, you can actually use it in S as well if you abstract out the
closure operation into a function <code>MC()</code> (for "make closure"):

<pre class="example">     dorder &lt;- function(n, r, pfun, dfun) {
       con &lt;- round(exp(lgamma(n + 1) - lgamma(r) - lgamma(n - r + 1)))
       MC(function(x) {
            con * pfun(x)^(r - 1) * (1 - pfun(x))^(n - r) * dfun(x)
          },
          list(con = con, pfun = pfun, dfun = dfun, r = r, n = n))
     }
     </pre>

   <p>Given the appropriate definitions of the closure operator, this works in
both R and S, and is much "cleaner" than a substitute/eval solution
(or one which overrules the default scoping rules by using explicit
access to evaluation frames, as is of course possible in both R and S).

   <p>For R, <code>MC()</code> simply is

<pre class="example">     MC &lt;- function(f, env) f
     </pre>

<p>(lexical scope!), a version for S is

<pre class="example">     MC &lt;- function(f, env = NULL) {
       env &lt;- as.list(env)
       if (mode(f) != "function")
         stop(paste("not a function:", f))
       if (length(env) &gt; 0 &amp;&amp; any(names(env) == ""))
         stop(paste("not all arguments are named:", env))
       fargs &lt;- if(length(f) &gt; 1) f[1:(length(f) - 1)] else NULL
       fargs &lt;- c(fargs, env)
       if (any(duplicated(names(fargs))))
         stop(paste("duplicated arguments:", paste(names(fargs)),
              collapse = ", "))
       fbody &lt;- f[length(f)]
       cf &lt;- c(fargs, fbody)
       mode(cf) &lt;- "function"
       return(cf)
     }
     </pre>

   <p>Similarly, most optimization (or zero-finding) routines need some
arguments to be optimized over and have other parameters that depend on
the data but are fixed with respect to optimization.  With R scoping
rules, this is a trivial problem; simply make up the function with the
required definitions in the same environment and scoping takes care of
it.  With S, one solution is to add an extra parameter to the function
and to the optimizer to pass in these extras, which however can only
work if the optimizer supports this.

   <p>Lexical scoping allows using function closures and maintaining local
state.  A simple example (taken from Abelson and Sussman) is obtained by
typing <kbd>demo("scoping")</kbd> at the R prompt.  Further information is
provided in the standard R reference "R: A Language for Data Analysis
and Graphics" (see <a href="#What%20documentation%20exists%20for%20R%3f">What documentation exists for R?</a>) and in Robert
Gentleman and Ross Ihaka (2000), "Lexical Scope and Statistical
Computing", <a href="http://www.amstat.org/publications/jcgs/"><em>Journal of Computational and Graphical Statistics</em></a>, <strong>9</strong>,
491-508.

   <p>Lexical scoping also implies a further major difference.  Whereas S
stores all objects as separate files in a directory somewhere (usually
<code>.Data</code> under the current directory), R does not.  All objects in R
are stored internally.  When R is started up it grabs a piece of memory
and uses it to store the objects.  R performs its own memory management
of this piece of memory, growing and shrinking its size as needed. 
Having everything in memory is necessary because it is not really
possible to externally maintain all relevant "environments" of
symbol/value pairs.  This difference also seems to make R <em>faster</em>
than S.

   <p>The down side is that if R crashes you will lose all the work for the
current session.  Saving and restoring the memory "images" (the
functions and data stored in R's internal memory at any time) can be a
bit slow, especially if they are big.  In S this does not happen,
because everything is saved in disk files and if you crash nothing is
likely to happen to them.  (In fact, one might conjecture that the S
developers felt that the price of changing their approach to persistent
storage just to accommodate lexical scope was far too expensive.) 
Hence, when doing important work, you might consider saving often (see
<a href="#How%20can%20I%20save%20my%20workspace%3f">How can I save my workspace?</a>) to safeguard against possible
crashes.  Other possibilities are logging your sessions, or have your R
commands stored in text files which can be read in using
<code>source()</code>.

   <blockquote>
<strong>Note:</strong>  If you run R from within Emacs (see <a href="#R%20and%20Emacs">R and Emacs</a>),
you can save the contents of the interaction buffer to a file and
conveniently manipulate it using <code>ess-transcript-mode</code>, as well as
save source copies of all functions and data used. 
</blockquote>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Models">Models</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Others">Others</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Lexical%20scoping">Lexical scoping</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#What%20are%20the%20differences%20between%20R%20and%20S%3f">What are the differences between R and S?</a>
<br>
</div>

<h3 class="subsection">3.3.2 Models</h4>

<p>There are some differences in the modeling code, such as

     <ul>
<li>Whereas in S, you would use <code>lm(y ~ x^3)</code> to regress <code>y</code> on
<code>x^3</code>, in R, you have to insulate powers of numeric vectors (using
<code>I()</code>), i.e., you have to use <code>lm(y ~ I(x^3))</code>. 
<li>The glm family objects are implemented differently in R and S.  The same
functionality is available but the components have different names. 
<li>Option <code>na.action</code> is set to <code>"na.omit"</code> by default in R,
but not set in S. 
<li>Terms objects are stored differently.  In S a terms object is an
expression with attributes, in R it is a formula with attributes.  The
attributes have the same names but are mostly stored differently.  The
major difference in functionality is that a terms object is
subscriptable in S but not in R.  If you can't imagine why this would
matter then you don't need to know. 
<li>Finally, in R <code>y~x+0</code> is an alternative to <code>y~x-1</code> for
specifying a model with no intercept.  Models with no parameters at all
can be specified by <code>y~0</code>. 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Others">Others</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Models">Models</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#What%20are%20the%20differences%20between%20R%20and%20S%3f">What are the differences between R and S?</a>
<br>
</div>

<h3 class="subsection">3.3.3 Others</h4>

<p>Apart from lexical scoping and its implications, R follows the S
language definition in the Blue and White Books as much as possible, and
hence really is an "implementation" of S.  There are some intentional
differences where the behavior of S is considered "not clean".  In
general, the rationale is that R should help you detect programming
errors, while at the same time being as compatible as possible with S.

   <p>Some known differences are the following.

     <ul>

     <li>In R, if <code>x</code> is a list, then <code>x[i] &lt;- NULL</code> and <code>x[[i]]
&lt;- NULL</code> remove the specified elements from <code>x</code>.  The first of
these is incompatible with S, where it is a no-op.  (Note that you can
set elements to <code>NULL</code> using <code>x[i] &lt;- list(NULL)</code>.)

     <li>In S, the functions named <code>.First</code> and <code>.Last</code> in the
<code>.Data</code> directory can be used for customizing, as they are executed
at the very beginning and end of a session, respectively.

     <p>In R, the startup mechanism is as follows.  R first sources the system
startup file <code>$R_HOME/library/base/R/Rprofile</code>.  Then, it
searches for a site-wide startup profile unless the command line option
<code>--no-site-file</code> was given.  The name of this file is taken from
the value of the <code>R_PROFILE</code> environment variable.  If that variable
is unset, the default is <code>$R_HOME/etc/Rprofile.site</code>
(<code>$R_HOME/etc/Rprofile</code> in versions prior to 1.4.0).  This
code is loaded in package <strong>base</strong>.  Then, unless
<code>--no-init-file</code> was given, R searches for a file called
<code>.Rprofile</code> in the current directory or in the user's home
directory (in that order) and sources it into the user workspace.  It
then loads a saved image of the user workspace from <code>.RData</code> in
case there is one (unless <code>--no-restore</code> was specified).  If
needed, the functions <code>.First()</code> and <code>.Last()</code> should be
defined in the appropriate startup profiles.

     </p><li>In R, <code>T</code> and <code>F</code> are just variables being set to <code>TRUE</code>
and <code>FALSE</code>, respectively, but are not reserved words as in S and
hence can be overwritten by the user.  (This helps e.g. when you have
factors with levels <code>"T"</code> or <code>"F"</code>.)  Hence, when writing code
you should always use <code>TRUE</code> and <code>FALSE</code>.

     <li>In R, <code>dyn.load()</code> can only load <em>shared objects</em>, as created
for example by <kbd>R CMD SHLIB</kbd>.

     <li>In R, <code>attach()</code> currently only works for lists and data frames,
but not for directories.  (In fact, <code>attach()</code> also works for R
data files created with <code>save()</code>, which is analogous to attaching
directories in S.)  Also, you cannot attach at position 1.

     <li>Categories do not exist in R, and never will as they are deprecated now
in S.  Use factors instead.

     <li>In R, <code>For()</code> loops are not necessary and hence not supported.

     <li>In R, <code>assign()</code> uses the argument <code>envir=</code> rather than
<code>where=</code> as in S.

     <li>The random number generators are different, and the seeds have different
length.

     <li>R passes integer objects to C as <code>int *</code> rather than <code>long *</code>
as in S.

     <li>R has no single precision storage mode.  However, as of version 0.65.1,
there is a single precision interface to C/FORTRAN subroutines.

     <li>By default, <code>ls()</code> returns the names of the objects in the current
(under R) and global (under S) environment, respectively.  For example,
given

     <pre class="example">          x &lt;- 1; fun &lt;- function() {y &lt;- 1; ls()}
          </pre>

     <p>then <code>fun()</code> returns <code>"y"</code> in R and <code>"x"</code> (together with
the rest of the global environment) in S.

     </p><li>R allows for zero-extent matrices (and arrays, i.e., some elements of
the <code>dim</code> attribute vector can be 0).  This has been determined a
useful feature as it helps reducing the need for special-case tests for
empty subsets.  For example, if <code>x</code> is a matrix, <code>x[, FALSE]</code>
is not <code>NULL</code> but a "matrix" with 0 columns.  Hence, such objects
need to be tested for by checking whether their <code>length()</code> is zero
(which works in both R and S), and not using <code>is.null()</code>.

     <li>Named vectors are considered vectors in R but not in S (e.g.,
<code>is.vector(c(a = 1:3))</code> returns <code>FALSE</code> in S and <code>TRUE</code>
in R).

     <li>Data frames are not considered as matrices in R (i.e., if <code>DF</code> is a
data frame, then <code>is.matrix(DF)</code> returns <code>FALSE</code> in R and
<code>TRUE</code> in S).

     <li>R by default uses treatment contrasts in the unordered case, whereas S
uses the Helmert ones.  This is a deliberate difference reflecting the
opinion that treatment contrasts are more natural.

     <li>In R, the argument of a replacement function which corresponds to the
right hand side must be named <code>value</code>.  E.g., <code>f(a) &lt;- b</code> is
evaluated as <code>a &lt;- "f&lt;-"(a, value = b)</code>.  S always takes the last
argument, irrespective of its name.

     <li>In S, <code>substitute()</code> searches for names for substitution in the
given expression in three places: the actual and the default arguments
of the matching call, and the local frame (in that order).  R looks in
the local frame only, with the special rule to use a "promise" if a
variable is not evaluated.  Since the local frame is initialized with
the actual arguments or the default expressions, this is usually
equivalent to S, until assignment takes place.

     <li>In S, the index variable in a <code>for()</code> loop is local to the inside
of the loop.  In R it is local to the environment where the <code>for()</code>
statement is executed.

     <li>In S, <code>tapply(simplify=TRUE)</code> returns a vector where R returns a
one-dimensional array (which can have named dimnames).

     <li>In S(-<small>PLUS</small>) the C locale is used, whereas in R the current
operating system locale is used for determining which characters are
alphanumeric and how they are sorted.  This affects the set of valid
names for R objects (for example accented chars may be allowed in R) and
ordering in sorts and comparisons (such as whether <code>"aA" &lt; "Bb"</code> is
true or false).  From version 1.2.0 the locale can be (re-)set in R by
the <code>Sys.setlocale()</code> function.

     <li>In S, <code>missing(</code><var>arg</var><code>)</code> remains <code>TRUE</code> if <var>arg</var> is
subsequently modified; in R it doesn't.

     <li>From R version 1.3.0, <code>data.frame</code> strips <code>I()</code> when creating
(column) names.

     <li>In R, the string <code>"NA"</code> is not treated as a missing value in a
character variable.  Use <code>as.character(NA)</code> to create a missing
character value.

     <li>R disallows repeated formal arguments in function calls.

   </ul>

   <p>There are also differences which are not intentional, and result from
missing or incorrect code in R.  The developers would appreciate hearing
about any deficiencies you may find (in a written report fully
documenting the difference as you see it).  Of course, it would be
useful if you were to implement the change yourself and make sure it
works.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Is%20there%20anything%20R%20can%20do%20that%20S-PLUS%20cannot%3f">Is there anything R can do that S-PLUS cannot?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#What%20is%20R-plus%3f">What is R-plus?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20are%20the%20differences%20between%20R%20and%20S%3f">What are the differences between R and S?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20and%20S">R and S</a>
<br>
</div>

<h3 class="section">3.4 Is there anything R can do that <small>S-PLUS</small> cannot?</h3>

<p>Since almost anything you can do in R has source code that you could
port to <small>S-PLUS</small> with little effort there will never be much you can do
in R that you couldn't do in <small>S-PLUS</small> if you wanted to.  (Note that
using lexical scoping may simplify matters considerably, though.)

   <p>R offers several graphics features that <small>S-PLUS</small> does not, such as finer
handling of line types, more convenient color handling (via palettes),
gamma correction for color, and, most importantly, mathematical
annotation in plot texts, via input expressions reminiscent of TeX
constructs.  See the help page for <code>plotmath</code>, which features an
impressive on-line example.  More details can be found in Paul Murrell
and Ross Ihaka (2000), "An Approach to Providing Mathematical
Annotation in Plots", <a href="http://www.amstat.org/publications/jcgs/"><em>Journal of Computational and Graphical Statistics</em></a>, <strong>9</strong>,
582-599.

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20is%20R-plus%3f">What is R-plus?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Is%20there%20anything%20R%20can%20do%20that%20S-PLUS%20cannot%3f">Is there anything R can do that S-PLUS cannot?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20and%20S">R and S</a>
<br>
</div>

<h3 class="section">3.5 What is R-plus?</h3>

<p>There is no such thing.

<div class="node">
<p><hr>
Node:&nbsp;<a name="R%20Web%20Interfaces">R Web Interfaces</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#R%20Add-On%20Packages">R Add-On Packages</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20and%20S">R and S</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>
<br>
</div>

<h2 class="chapter">4 R Web Interfaces</h2>

<p><strong>Rweb</strong> is developed and maintained by
<a href="mailto:jeff@math.montana.edu">Jeff Banfield</a>.  The
<a href="http://www.math.montana.edu/Rweb/">Rweb Home Page</a> provides access
to all three versions of Rweb--a simple text entry form that returns
output and graphs, a more sophisticated Javascript version that provides
a multiple window environment, and a set of point and click modules that
are useful for introductory statistics courses and require no knowledge
of the R language.  All of the Rweb versions can analyze Web accessible
datasets if a <small>URL</small> is provided.

   <p>The paper "Rweb: Web-based Statistical Analysis", providing a detailed
explanation of the different versions of Rweb and an overview of how
Rweb works, was published in the Journal of Statistical Software
(<a href="http://www.stat.ucla.edu/journals/jss/v04/i01/">http://www.stat.ucla.edu/journals/jss/v04/i01/</a>).

   <a href="mailto:ulfi@cs.tu-berlin.de">Ulf Bartel</a> is working on
<strong>R-Online</strong>, a simple on-line programming environment for R which
intends to make the first steps in statistical programming with R
(especially with time series) as easy as possible.  There is no need for
a local installation since the only requirement for the user is a
JavaScript capable browser.  See <a href="http://osvisions.com/r-online/">http://osvisions.com/r-online/</a>
for more information.

   <p><strong>CGIwithR</strong> is an R add-on package by
<a href="mailto:david.firth@nuffield.ox.ac.uk">David Firth</a> and has its home
page at <a href="http://www.stats.ox.ac.uk/~firth/CGIwithR/index.html">http://www.stats.ox.ac.uk/~firth/CGIwithR/index.html</a>.  It
provides some simple extensions to R to facilitate running R scripts
through the CGI interface to a web server.  It is easily installed using
Apache under Linux and in principle should run on any platform that
supports R and a web server provided that the installer has the
necessary security permissions.

   <p><strong>Rcgi</strong> is a CGI WWW interface to R by
<a href="mailto:mjr@stats.mth.uea.ac.uk">Mark J. Ray</a>.  It had the ability to
use "embedded code": you could mix user input and code, allowing the
<small>HTML</small> author to do anything from load in data sets to enter most of
the commands for users without writing CGI scripts.  Graphical output
was possible in PostScript or GIF formats and the executed code was
presented to the user for revision.  However, it is not clear if the
project is still active and recent attempts to contact the author or
find the package have failed.

<div class="node">
<p><hr>
Node:&nbsp;<a name="R%20Add-On%20Packages">R Add-On Packages</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#R%20and%20Emacs">R and Emacs</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20Web%20Interfaces">R Web Interfaces</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>
<br>
</div>

<h2 class="chapter">5 R Add-On Packages</h2>

<ul class="menu">
<li><a accesskey="1" href="#Which%20add-on%20packages%20exist%20for%20R%3f">Which add-on packages exist for R?</a>: 
<li><a accesskey="2" href="#How%20can%20add-on%20packages%20be%20installed%3f">How can add-on packages be installed?</a>: 
<li><a accesskey="3" href="#How%20can%20add-on%20packages%20be%20used%3f">How can add-on packages be used?</a>: 
<li><a accesskey="4" href="#How%20can%20add-on%20packages%20be%20removed%3f">How can add-on packages be removed?</a>: 
<li><a accesskey="5" href="#How%20can%20I%20create%20an%20R%20package%3f">How can I create an R package?</a>: 
<li><a accesskey="6" href="#How%20can%20I%20contribute%20to%20R%3f">How can I contribute to R?</a>: 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Which%20add-on%20packages%20exist%20for%20R%3f">Which add-on packages exist for R?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20add-on%20packages%20be%20installed%3f">How can add-on packages be installed?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20Add-On%20Packages">R Add-On Packages</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Add-On%20Packages">R Add-On Packages</a>
<br>
</div>

<h3 class="section">5.1 Which add-on packages exist for R?</h3>

<ul class="menu">
<li><a accesskey="1" href="#Add-on%20packages%20in%20R">Add-on packages in R</a>: 
<li><a accesskey="2" href="#Add-on%20packages%20from%20CRAN">Add-on packages from CRAN</a>: 
<li><a accesskey="3" href="#Add-on%20packages%20from%20Omegahat">Add-on packages from Omegahat</a>: 
<li><a accesskey="4" href="#Add-on%20packages%20from%20BioConductor">Add-on packages from BioConductor</a>: 
<li><a accesskey="5" href="#Other%20add-on%20packages">Other add-on packages</a>: 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Add-on%20packages%20in%20R">Add-on packages in R</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Add-on%20packages%20from%20CRAN">Add-on packages from CRAN</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Which%20add-on%20packages%20exist%20for%20R%3f">Which add-on packages exist for R?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Which%20add-on%20packages%20exist%20for%20R%3f">Which add-on packages exist for R?</a>
<br>
</div>

<h3 class="subsection">5.1.1 Add-on packages in R</h4>

<p>The R distribution comes with the following extra packages:

     <dl>
<dt><strong>ctest</strong>
     <dd>A collection of Classical TESTs, including the Ansari-Bradley, Bartlett,
chi-squared, Fisher, Kruskal-Wallis, Kolmogorov-Smirnov, t, and
Wilcoxon tests. 
<br><dt><strong>eda</strong>
     <dd>Exploratory Data Analysis.  Currently only contains functions for robust
line fitting, and median polish and smoothing. 
<br><dt><strong>grid</strong>
     <dd>A rewrite of the graphics layout capabilities, plus some support for
interaction. 
(Added in R 1.8.0). 
<br><dt><strong>lqs</strong>
     <dd>Resistant regression and covariance estimation. 
<br><dt><strong>methods</strong>
     <dd>Formally defined methods and classes for R objects, plus other
programming tools, as described in the Green Book. 
<br><dt><strong>mle</strong>
     <dd>Generic (smooth) likelihood maximization and profiling. 
(Added in R 1.8.0). 
<br><dt><strong>modreg</strong>
     <dd>MODern REGression: smoothing and local methods. 
<br><dt><strong>mva</strong>
     <dd>MultiVariate Analysis.  Currently contains code for principal
components, canonical correlations, metric multidimensional scaling,
factor analysis, and hierarchical and k-means clustering. 
<br><dt><strong>nls</strong>
     <dd>Nonlinear regression routines. 
<br><dt><strong>splines</strong>
     <dd>Regression spline functions and classes. 
<br><dt><strong>stepfun</strong>
     <dd>Code for dealing with STEP FUNctions, including empirical cumulative
distribution functions. 
<br><dt><strong>tcltk</strong>
     <dd>Interface and language bindings to Tcl/Tk <small>GUI</small> elements. 
<br><dt><strong>tools</strong>
     <dd>Tools for package development and administration. 
<br><dt><strong>ts</strong>
     <dd>Time Series. 
</dl>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Add-on%20packages%20from%20CRAN">Add-on packages from CRAN</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Add-on%20packages%20from%20Omegahat">Add-on packages from Omegahat</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Add-on%20packages%20in%20R">Add-on packages in R</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Which%20add-on%20packages%20exist%20for%20R%3f">Which add-on packages exist for R?</a>
<br>
</div>

<h3 class="subsection">5.1.2 Add-on packages from <small>CRAN</small></h4>

<p>The following packages are available from the <small>CRAN</small> <code>src/contrib</code>
area.  (Packages denoted as <em>Recommended</em> are to be included in all
binary distributions of R.)

     <dl>
<dt><strong>AnalyzeFMRI</strong>
     <dd>Functions for I/O, visualisation and analysis of functional Magnetic
Resonance Imaging (fMRI) datasets stored in the ANALYZE format. 
<br><dt><strong>Bhat</strong>
     <dd>Functions for general likelihood exploration (MLE, MCMC, CIs). 
<br><dt><strong>CDNmoney</strong>
     <dd>Components of Canadian monetary aggregates. 
<br><dt><strong>CGIwithR</strong>
     <dd>Facilities for the use of R to write CGI scripts. 
<br><dt><strong>CircStats</strong>
     <dd>Circular Statistics, from "Topics in Circular Statistics" by S. Rao
Jammalamadaka and A. SenGupta, 2001, World Scientific. 
<br><dt><strong>CoCoAn</strong>
     <dd>Constrained Correspondence Analysis. 
<br><dt><strong>DAAG</strong>
     <dd>Various data sets used in examples and exercises in "Data Analysis and
Graphics Using R" by John H. Maindonald and W. John Brown, 2003. 
<br><dt><strong>DBI</strong>
     <dd>A common database interface (DBI) class and method definitions.  All
classes in this package are virtual and need to be extended by the
various DBMS implementations. 
<br><dt><strong>Davies</strong>
     <dd>Functions for the Davies quantile function and the Generalized Lambda
distribution. 
<br><dt><strong>Design</strong>
     <dd>Regression modeling, testing, estimation, validation, graphics,
prediction, and typesetting by storing enhanced model design attributes
in the fit.  Design is a collection of about 180 functions that assist
and streamline modeling, especially for biostatistical and epidemiologic
applications.  It also contains new functions for binary and ordinal
logistic regression models and the Buckley-James multiple regression
model for right-censored responses, and implements penalized maximum
likelihood estimation for logistic and ordinary linear models.  Design
works with almost any regression model, but it was especially written to
work with logistic regression, Cox regression, accelerated failure time
models, ordinary linear models, and the Buckley-James model. 
<br><dt><strong>Devore5</strong>
     <dd>Data sets and sample analyses from "Probability and Statistics for
Engineering and the Sciences (5th ed)" by Jay L. Devore, 2000, Duxbury. 
<br><dt><strong>Devore6</strong>
     <dd>Data sets and sample analyses from "Probability and Statistics for
Engineering and the Sciences (6th ed)" by Jay L. Devore, 2003, Duxbury. 
<br><dt><strong>GRASS</strong>
     <dd>An interface between the GRASS geographical information system and R,
based on starting R from within the GRASS environment and chosen
LOCATION_NAME and MAPSET.  Wrapper and helper functions are provided for
a range of R functions to match the interface metadata structures. 
<br><dt><strong>GenKern</strong>
     <dd>Functions for generating and manipulating generalised binned kernel
density estimates. 
<br><dt><strong>HI</strong>
     <dd>Simulation from distributions supported by nested hyperplanes. 
<br><dt><strong>Hmisc</strong>
     <dd>Functions useful for data analysis, high-level graphics, utility
operations, functions for computing sample size and power, importing
datasets, imputing missing values, advanced table making, variable
clustering, character string manipulation, conversion of S objects to
LaTeX code, recoding variables, and bootstrap repeated measures
analysis. 
<br><dt><strong>HyperbolicDist</strong>
     <dd>Basic functions for the hyperbolic distribution: probability density
function, distribution function, quantile function, a routine for
generating observations from the hyperbolic, and a function for fitting
the hyperbolic distribution to data. 
<br><dt><strong>ISwR</strong>
     <dd>Data sets for "Introductory Statistics with R" by Peter Dalgaard,
2002, Springer. 
<br><dt><strong>KMsurv</strong>
     <dd>Data sets and functions for "Survival Analysis, Techniques for Censored
and Truncated Data" by Klein and Moeschberger, 1997, Springer. 
<br><dt><strong>KernSmooth</strong>
     <dd>Functions for kernel smoothing (and density estimation) corresponding to
the book "Kernel Smoothing" by M. P. Wand and M. C. Jones, 1995. 
<em>Recommended</em>. 
<br><dt><strong>MASS</strong>
     <dd>Functions and datasets from the main package of Venables and Ripley,
"Modern Applied Statistics with S".  Contained in the <code>VR</code>
bundle.  <em>Recommended</em>. 
<br><dt><strong>MCMCpack</strong>
     <dd>Markov chain Monte Carlo (MCMC) package: functions for posterior
simulation for a number of statistical models. 
<br><dt><strong>MPV</strong>
     <dd>Data sets from the book "Introduction to Linear Regression Analysis"
by D. C. Montgomery, E. A. Peck, and C. G. Vining, 2001, John Wiley and
Sons. 
<br><dt><strong>Matrix</strong>
     <dd>A Matrix package. 
<br><dt><strong>NISTnls</strong>
     <dd>A set of test nonlinear least squares examples from <small>NIST</small>, the
U.S. National Institute for Standards and Technology. 
<br><dt><strong>Oarray</strong>
     <dd>Arrays with arbitrary offsets. 
<br><dt><strong>PHYLOGR</strong>
     <dd>Manipulation and analysis of phylogenetically simulated data sets (as
obtained from PDSIMUL in package PDAP) and phylogenetically-based
analyses using GLS. 
<br><dt><strong>PTAk</strong>
     <dd>A multiway method to decompose a tensor (array) of any order, as a
generalisation of SVD also supporting non-identity metrics and
penalisations.  Also includes some other multiway methods. 
<br><dt><strong>R2HTML</strong>
     <dd>Functions for exporting R objects &amp; graphics in an <small>HTML</small> document. 
<br><dt><strong>RArcInfo</strong>
     <dd>Functions to import Arc/Info V7.x coverages and data. 
<br><dt><strong>RColorBrewer</strong>
     <dd>ColorBrewer palettes for drawing nice maps shaded according to a
variable. 
<br><dt><strong>RMySQL</strong>
     <dd>An interface between R and the MySQL database system. 
<br><dt><strong>RODBC</strong>
     <dd>An <small>ODBC</small> database interface. 
<br><dt><strong>ROracle</strong>
     <dd>Oracle Database Interface driver for R.  Uses the ProC/C++ embedded SQL. 
<br><dt><strong>RQuantLib</strong>
     <dd>Provides access to (some) of the QuantLib functions from within R;
currently limited to some Option pricing and analysis functions.  The
QuantLib project aims to provide a comprehensive software framework for
quantitative finance. 
<br><dt><strong>RSQLite</strong>
     <dd>Database Interface R driver for SQLite.  Embeds the SQLite database
engine in R. 
<br><dt><strong>RSvgDevice</strong>
     <dd>A graphics device for R that uses the new w3.org <small>XML</small> standard for
Scalable Vector Graphics. 
<br><dt><strong>RadioSonde</strong>
     <dd>A collection of programs for reading and plotting SKEW-T,log p diagrams
and wind profiles for data collected by radiosondes (the typical weather
balloon-borne instrument). 
<br><dt><strong>RandomFields</strong>
     <dd>Creating random fields using various methods. 
<br><dt><strong>Rcmdr</strong>
     <dd>A platform-independent basic-statistics GUI (graphical user interface)
for R, based on the <strong>tcltk</strong> package. 
<br><dt><strong>RmSQL</strong>
     <dd>An interface between R and the mSQL database system. 
<br><dt><strong>Rwave</strong>
     <dd>An environment for the time-frequency analysis of 1-D signals (and
especially for the wavelet and Gabor transforms of noisy signals), based
on the book "Practical Time-Frequency Analysis: Gabor and Wavelet
Transforms with an Implementation in S" by Rene Carmona, Wen L. Hwang
and Bruno Torresani, 1998, Academic Press. 
<br><dt><strong>SASmixed</strong>
     <dd>Data sets and sample linear mixed effects analyses corresponding to the
examples in "SAS System for Mixed Models" by R. C. Littell,
G. A. Milliken, W. W. Stroup and R. D. Wolfinger, 1996, SAS Institute. 
<br><dt><strong>SenSrivastava</strong>
     <dd>Collection of datasets from "Regression Analysis, Theory, Methods and
Applications" by A. Sen and M. Srivastava, 1990, Springer-Verlag. 
<br><dt><strong>SparseM</strong>
     <dd>Basic linear algebra for sparse matrices. 
<br><dt><strong>StatDataML</strong>
     <dd>Read and write StatDataML. 
<br><dt><strong>SuppDists</strong>
     <dd>Ten distributions supplementing those built into R (Inverse Gauss,
Kruskal-Wallis, Kendall's Tau, Friedman's chi squared, Spearman's rho,
maximum F ratio, the Pearson product moment correlation coefficiant,
Johnson distributions, normal scores and generalized hypergeometric
distributions). 
<br><dt><strong>VLMC</strong>
     <dd>Functions, classes &amp; methods for estimation, prediction, and simulation
(bootstrap) of VLMC (Variable Length Markov Chain) models. 
<br><dt><strong>VaR</strong>
     <dd>Methods for calculation of Value at Risk (VaR). 
<br><dt><strong>XML</strong>
     <dd>Facilities for reading <small>XML</small> documents and DTDs. 
<br><dt><strong>abind</strong>
     <dd>Combine multi-dimensional arrays. 
<br><dt><strong>acepack</strong>
     <dd>ACE (Alternating Conditional Expectations) and AVAS (Additivity and
VAriance Stabilization for regression) methods for selecting regression
transformations. 
<br><dt><strong>adapt</strong>
     <dd>Adaptive quadrature in up to 20 dimensions. 
<br><dt><strong>ade4</strong>
     <dd>Multivariate data analysis and graphical display. 
<br><dt><strong>agce</strong>
     <dd>Analysis of growth curve experiments. 
<br><dt><strong>akima</strong>
     <dd>Linear or cubic spline interpolation for irregularly gridded data. 
<br><dt><strong>amap</strong>
     <dd>Another Multidimensional Analysis Package. 
<br><dt><strong>anm</strong>
     <dd>Analog model for statistical/empirical downscaling. 
<br><dt><strong>ape</strong>
     <dd>Analyses of Phylogenetics and Evolution, providing functions for reading
and plotting phylogenetic trees in parenthetic format (standard Newick
format), analyses of comparative data in a phylogenetic framework,
analyses of diversification and macroevolution, computing distances from
allelic and nucleotide data, reading nucleotide sequences from GenBank
via internet, and several tools such as Mantel's test, computation of
minimum spanning tree, or the population parameter theta based on
various approaches. 
<br><dt><strong>ash</strong>
     <dd>David Scott's ASH routines for 1D and 2D density estimation. 
<br><dt><strong>aws</strong>
     <dd>Functions to perform adaptive weights smoothing. 
<br><dt><strong>bim</strong>
     <dd>Bayesian interval mapping diagnostics:  functions to interpret QTLCart
and Bmapqtl samples. 
<br><dt><strong>bindata</strong>
     <dd>Generation of correlated artificial binary data. 
<br><dt><strong>blighty</strong>
     <dd>Function for drawing the coastline of the United Kingdom. 
<br><dt><strong>boolean</strong>
     <dd>Boolean logit and probit: a procedure for testing Boolean hypotheses. 
<br><dt><strong>boot</strong>
     <dd>Functions and datasets for bootstrapping from the book "Bootstrap
Methods and Their Applications" by A. C. Davison and D. V. Hinkley,
1997, Cambridge University Press.  <em>Recommended</em>. 
<br><dt><strong>bootstrap</strong>
     <dd>Software (bootstrap, cross-validation, jackknife), data and errata for
the book "An Introduction to the Bootstrap" by B. Efron and
R. Tibshirani, 1993, Chapman and Hall. 
<br><dt><strong>bqtl</strong>
     <dd>QTL mapping toolkit for inbred crosses and recombinant inbred lines. 
Includes maximum likelihood and Bayesian tools. 
<br><dt><strong>brlr</strong>
     <dd>Bias-reduced logistic regression: fits logistic regression models by
maximum penalized likelihood. 
<br><dt><strong>car</strong>
     <dd>Companion to Applied Regression, containing functions for applied
regession, linear models, and generalized linear models, with an
emphasis on regression diagnostics, particularly graphical diagnostic
methods. 
<br><dt><strong>cat</strong>
     <dd>Analysis of categorical-variable datasets with missing values. 
<br><dt><strong>cclust</strong>
     <dd>Convex clustering methods, including k-means algorithm, on-line
update algorithm (Hard Competitive Learning) and Neural Gas algorithm
(Soft Competitive Learning) and calculation of several indexes for
finding the number of clusters in a data set. 
<br><dt><strong>cfa</strong>
     <dd>Analysis of configuration frequencies. 
<br><dt><strong>chron</strong>
     <dd>A package for working with chronological objects (times and dates). 
<br><dt><strong>class</strong>
     <dd>Functions for classification (k-nearest neighbor and LVQ). 
Contained in the <code>VR</code> bundle.  <em>Recommended</em>. 
<br><dt><strong>classPP</strong>
     <dd>Projection Pursuit for supervised classification. 
<br><dt><strong>clim.pact</strong>
     <dd>Climate analysis and downscaling for monthly and daily data. 
<br><dt><strong>clines</strong>
     <dd>Calculates Contour Lines. 
<br><dt><strong>cluster</strong>
     <dd>Functions for cluster analysis.  <em>Recommended</em>. 
<br><dt><strong>cmprsk</strong>
     <dd>Estimation, testing and regression modeling of subdistribution functions
in competing risks. 
<br><dt><strong>cobs</strong>
     <dd>Constrained B-splines: qualitatively constrained (regression) smoothing
via linear programming. 
<br><dt><strong>coda</strong>
     <dd>Output analysis and diagnostics for Markov Chain Monte Carlo (MCMC)
simulations. 
<br><dt><strong>combinat</strong>
     <dd>Combinatorics utilities. 
<br><dt><strong>conf.design</strong>
     <dd>A series of simple tools for constructing and manipulating confounded
and fractional factorial designs. 
<br><dt><strong>cramer</strong>
     <dd>Routine for the multivariate nonparametric Cramer test. 
<br><dt><strong>date</strong>
     <dd>Functions for dealing with dates.  The most useful of them accepts a
vector of input dates in any of the forms <code>8/30/53</code>,
<code>30Aug53</code>, <code>30 August 1953</code>, <small class="dots">...</small>, <code>August 30 53</code>, or
any mixture of these. 
<br><dt><strong>dblcens</strong>
     <dd>Calculates the NPMLE of the survival distribution for doubly censored
data. 
<br><dt><strong>deal</strong>
     <dd>Bayesian networks with continuous and/or discrete variables can be
learned and compared from data. 
<br><dt><strong>deldir</strong>
     <dd>Calculates the  Delaunay triangulation and the Dirichlet or Voronoi
tesselation (with respect to the entire plane) of a planar point set. 
<br><dt><strong>diamonds</strong>
     <dd>Functions for illustrating aperture-4 diamond partitions in the plane,
or on the surface of an octahedron or icosahedron, for use as analysis
or sampling grids. 
<br><dt><strong>dichromat</strong>
     <dd>Color schemes for dichromats: collapse red-green distinctions to
simulate the effects of colour-blindness. 
<br><dt><strong>diptest</strong>
     <dd>Compute Hartigan's dip test statistic for unimodality. 
<br><dt><strong>dispmod</strong>
     <dd>Functions for modelling dispersion in GLMs. 
<br><dt><strong>dr</strong>
     <dd>Functions, methods, and datasets for fitting dimension reduction
regression, including pHd and inverse regression methods SIR and SAVE. 
<br><dt><strong>dse</strong>
     <dd>Dynamic System Estimation, a multivariate time series package.  Contains
<strong>dse1</strong> (the base system, including multivariate ARMA and state
space models), <strong>dse2</strong> (extensions for evaluating estimation
techniques, forecasting, and for evaluating forecasting model),
<strong>tframe</strong> (functions for writing code that is independent of the
representation of time). and <strong>setRNG</strong> (a mechanism for generating
the same random numbers in S and R). 
<br><dt><strong>e1071</strong>
     <dd>Miscellaneous functions used at the Department of Statistics at TU Wien
(E1071), including moments, short-time Fourier transforms, Independent
Component Analysis, Latent Class Analysis, support vector machines, and
fuzzy clustering, shortest path computation, bagged clustering, and some
more. 
<br><dt><strong>effects</strong>
     <dd>Graphical and tabular effect displays, e.g., of interactions, for linear
and generalised linear models. 
<br><dt><strong>eha</strong>
     <dd>A package for survival and event history analysis. 
<br><dt><strong>ellipse</strong>
     <dd>Package for drawing ellipses and ellipse-like confidence regions. 
<br><dt><strong>emme2</strong>
     <dd>Functions to read from and write to an EMME/2 databank. 
<br><dt><strong>emplik</strong>
     <dd>Empirical likelihood ratio for means/quantiles/hazards from possibly
right censored data. 
<br><dt><strong>evd</strong>
     <dd>Functions for extreme value distributions.  Extends simulation,
distribution, quantile and density functions to univariate, bivariate
and (for simulation) multivariate parametric extreme value
distributions, and provides fitting functions which calculate maximum
likelihood estimates for univariate and bivariate models. 
<br><dt><strong>exactLoglinTest</strong>
     <dd>Monte Carlo exact tests for log-linear models. 
<br><dt><strong>exactRankTests</strong>
     <dd>Computes exact p-values and quantiles using an implementation of
the Streitberg/Roehmel shift algorithm. 
<br><dt><strong>fastICA</strong>
     <dd>Implementation of FastICA algorithm to perform Independent Component
Analysis (ICA) and Projection Pursuit. 
<br><dt><strong>fdim</strong>
     <dd>Functions for calculating fractal dimension. 
<br><dt><strong>fields</strong>
     <dd>A collection of programs for curve and function fitting with an emphasis
on spatial data.  The major methods implemented include cubic and thin
plate splines, universal Kriging and Kriging for large data sets.  The
main feature is that any covariance function implemented in R can be
used for spatial prediction. 
<br><dt><strong>flexmix</strong>
     <dd>Flexible Mixture Modeling: a general framework for finite mixtures of
regression models using the EM algorithm. 
<br><dt><strong>foreign</strong>
     <dd>Functions for reading and writing data stored by statistical software
like Minitab, SAS, SPSS, Stata, etc.  <em>Recommended</em>. 
<br><dt><strong>forward</strong>
     <dd>Forward search approach to robust analysis in linear and generalized
linear regression models. 
<br><dt><strong>fpc</strong>
     <dd>Fixed point clusters, clusterwise regression and discriminant plots. 
<br><dt><strong>fracdiff</strong>
     <dd>Maximum likelihood estimation of the parameters of a fractionally
differenced ARIMA(p,d,q) model (Haslett and Raftery, Applied
Statistics, 1989). 
<br><dt><strong>ftnonpar</strong>
     <dd>Features and strings for nonparametric regression. 
<br><dt><strong>g.data</strong>
     <dd>Create and maintain delayed-data packages (DDP's). 
<br><dt><strong>gafit</strong>
     <dd>Genetic algorithm for curve fitting. 
<br><dt><strong>gbm</strong>
     <dd>Generalized Boosted Regression Models: implements extensions to Freund
and Schapire's AdaBoost algorithm and J. Friedman's gradient boosting
machine.  Includes regression methods for least squares, absolute loss,
logistic, Poisson, Cox proportional hazards partial likelihood, and
AdaBoost exponential loss. 
<br><dt><strong>gee</strong>
     <dd>An implementation of the Liang/Zeger generalized estimating equation
approach to GLMs for dependent data. 
<br><dt><strong>geepack</strong>
     <dd>Generalized estimating equations solver for parameters in mean, scale,
and correlation structures, through mean link, scale link, and
correlation link.  Can also handle clustered categorical responses. 
<br><dt><strong>genetics</strong>
     <dd>Classes and methods for handling genetic data.  Includes classes to
represent genotypes and haplotypes at single markers up to multiple
markers on multiple chromosomes, and functions for allele frequencies,
flagging homo/heterozygotes, flagging carriers of certain alleles,
computing disequlibrium, testing Hardy-Weinberg equilibrium, <small class="dots">...</small>
<br><dt><strong>geoR</strong>
     <dd>Functions to perform geostatistical data analysis including model-based
methods. 
<br><dt><strong>geoRglm</strong>
     <dd>Functions for inference in generalised linear spatial models. 
<br><dt><strong>ggm</strong>
     <dd>Functions for defining directed acyclic graphs and undirected graphs,
finding induced graphs and fitting Gaussian Markov models. 
<br><dt><strong>gld</strong>
     <dd>Basic functions for the generalised (Tukey) lambda distribution. 
<br><dt><strong>glmmML</strong>
     <dd>A Maximum Likelihood approach to generalized linear models with random
intercept. 
<br><dt><strong>gpclib</strong>
     <dd>General polygon clipping routines for R based on Alan Murta's C
library. 
<br><dt><strong>grasper</strong>
     <dd>Generalized Regression Analysis and Spatial Predictions for R. 
<br><dt><strong>gregmisc</strong>
     <dd>Miscellaneous functions written/maintained by Gregory R. Warnes. 
<br><dt><strong>gridBase</strong>
     <dd>Integration of base and grid graphics. 
<br><dt><strong>gss</strong>
     <dd>A comprehensive package for structural multivariate function estimation
using smoothing splines. 
<br><dt><strong>gstat</strong>
     <dd>multivariable geostatistical modelling, prediction and simulation. 
Includes code for variogram modelling; simple, ordinary and universal
point or block (co)kriging, sequential Gaussian or indicator
(co)simulation, and map plotting functions. 
<br><dt><strong>gtkDevice</strong>
     <dd>GTK graphics device driver that may be used independently of the R-GNOME
interface and can be used to create R devices as embedded components in
a GUI using a Gtk drawing area widget, e.g., using RGtk. 
<br><dt><strong>haplo.score</strong>
     <dd>Score tests for association of traits with haplotypes when linkage phase
is ambiguous. 
<br><dt><strong>hdf5</strong>
     <dd>Interface to the <small>NCSA</small> HDF5 library. 
<br><dt><strong>hier.part</strong>
     <dd>Hierarchical Partitioning: variance partition of a multivariate data
set. 
<br><dt><strong>homals</strong>
     <dd>Homogeneity Analysis (HOMALS) package with optional Tcl/Tk interface. 
<br><dt><strong>hwde</strong>
     <dd>Models and tests for departure from Hardy-Weinberg equilibrium and
independence between loci. 
<br><dt><strong>ifs</strong>
     <dd>Iterated Function Systems distribution function estimator. 
<br><dt><strong>ineq</strong>
     <dd>Inequality, concentration and poverty measures, and Lorenz curves
(empirical and theoretic). 
<br><dt><strong>ipred</strong>
     <dd>Improved predictive models by direct and indirect bootstrap aggregation
in classification and regression as well as resampling based estimators
of prediction error. 
<br><dt><strong>ismev</strong>
     <dd>Functions to support the computations carried out in "An Introduction
to Statistical Modeling of Extreme Values;' by S. Coles, 2001, Springer. 
The functions may be divided into the following groups; maxima/minima,
order statistics, peaks over thresholds and point processes. 
<br><dt><strong>its</strong>
     <dd>An S4 class for handling irregular time series. 
<br><dt><strong>knnTree</strong>
     <dd>Construct or predict with k-nearest-neighbor classifiers, using
cross-validation to select k, choose variables (by forward or
backwards selection), and choose scaling (from among no scaling, scaling
each column by its SD, or scaling each column by its MAD).  The finished
classifier will consist of a classification tree with one such
k-nn classifier in each leaf. 
<br><dt><strong>lars</strong>
     <dd>Least Angle Regression, Lasso and Forward Stagewise: efficient
procedures for fitting an entire lasso sequence with the cost of a
single least squares fit. 
<br><dt><strong>lasso2</strong>
     <dd>Routines and documentation for solving regression problems while
imposing an L1 constraint on the estimates, based on the algorithm of
Osborne et al. (1998)
<br><dt><strong>lattice</strong>
     <dd>Lattice graphics, an implementation of Trellis Graphics functions. 
<em>Recommended</em>. 
<br><dt><strong>leaps</strong>
     <dd>A package which performs an exhaustive search for the best subsets of a
given set of potential regressors, using a branch-and-bound algorithm,
and also performs searches using a number of less time-consuming
techniques. 
<br><dt><strong>lgtdl</strong>
     <dd>A set of methods for longitudinal data objects. 
<br><dt><strong>linprog</strong>
     <dd>Solve linear programming/linear optimization problems by using the
simplex algorithm. 
<br><dt><strong>lme4</strong>
     <dd>Fit linear and generalized linear mixed-effects models. 
<br><dt><strong>lmeSplines</strong>
     <dd>Fit smoothing spline terms in Gaussian linear and nonlinear
mixed-effects models. 
<br><dt><strong>lmtest</strong>
     <dd>A collection of tests on the assumptions of linear regression models
from the book "The linear regression model under test" by W. Kraemer
and H. Sonnberger, 1986, Physica. 
<br><dt><strong>locfit</strong>
     <dd>Local Regression, likelihood and density estimation. 
<br><dt><strong>logistf</strong>
     <dd>Firth's bias reduced logistic regression approach with penalized profile
likelihood based confidence intervals for parameter estimates. 
<br><dt><strong>logspline</strong>
     <dd>Logspline density estimation. 
<br><dt><strong>lokern</strong>
     <dd>Kernel regression smoothing with adaptive local or global plug-in
bandwidth selection. 
<br><dt><strong>lpSolve</strong>
     <dd>Functions that solve general linear/integer problems, assignment
problems, and transportation problems via interfacing Lp_solve. 
<br><dt><strong>lpridge</strong>
     <dd>Local polynomial (ridge) regression. 
<br><dt><strong>mapdata</strong>
     <dd>Supplement to package <strong>maps</strong>, providing the larger and/or
higher-resolution databases. 
<br><dt><strong>mapproj</strong>
     <dd>Map Projections: converts latitude/longitude into projected coordinates. 
<br><dt><strong>maps</strong>
     <dd>Draw geographical maps.  Projection code and larger maps are in separate
packages. 
<br><dt><strong>maptools</strong>
     <dd>Set of tools for manipulating and reading geographic data, in particular
ESRI shapefiles. 
<br><dt><strong>maptree</strong>
     <dd>Functions with example data for graphing and mapping models from
hierarchical clustering and classification and regression trees. 
<br><dt><strong>maxstat</strong>
     <dd>Maximally selected rank and Gauss statistics with several p-value
approximations. 
<br><dt><strong>mclust</strong>
     <dd>Model-based cluster analysis: the 2002 version of MCLUST. 
<br><dt><strong>mclust1998</strong>
     <dd>Model-based cluster analysis: the 1998 version of MCLUST. 
<br><dt><strong>mda</strong>
     <dd>Code for mixture discriminant analysis (MDA), flexible discriminant
analysis (FDA), penalized discriminant analysis (PDA), multivariate
additive regression splines (MARS), adaptive back-fitting splines
(BRUTO), and penalized regression. 
<br><dt><strong>merror</strong>
     <dd>Accuracy and precision of measurements. 
<br><dt><strong>mgcv</strong>
     <dd>Routines for GAMs and other genralized ridge regression problems with
multiple smoothing parameter selection by GCV or UBRE. 
<em>Recommended</em>. 
<br><dt><strong>mimR</strong>
     <dd>An R interface to MIM for graphical modeling in R. 
<br><dt><strong>mix</strong>
     <dd>Estimation/multiple imputation programs for mixed categorical and
continuous data. 
<br><dt><strong>mlbench</strong>
     <dd>A collection of artificial and real-world machine learning benchmark
problems, including the Boston housing data. 
<br><dt><strong>mmlcr</strong>
     <dd>Mixed-mode latent class regression (also known as mixed-mode mixture
model regression or mixed-mode mixture regression models) which can
handle both longitudinal and one-time responses. 
<br><dt><strong>moc</strong>
     <dd>Fits a variety of mixtures models for multivariate observations with
user-difined distributions and curves. 
<br><dt><strong>msm</strong>
     <dd>Functions for fitting continuous-time Markov multi-state models to
categorical processes observed at arbitrary times, optionally with
misclassified responses, and covariates on transition or
misclassification rates. 
<br><dt><strong>muhaz</strong>
     <dd>Hazard function estimation in survival analysis. 
<br><dt><strong>multcomp</strong>
     <dd>Multiple comparison procedures for the one-way layout. 
<br><dt><strong>multidim</strong>
     <dd>Multidimensional descriptive statistics: factorial methods and
classification. 
<br><dt><strong>multiv</strong>
     <dd>Functions for hierarchical clustering, partitioning, bond energy
algorithm, Sammon mapping, PCA and correspondence analysis. 
<br><dt><strong>mvnmle</strong>
     <dd>ML estimation for multivariate normal data with missing values. 
<br><dt><strong>mvnormtest</strong>
     <dd>Generalization of the Shapiro-Wilk test for multivariate variables. 
<br><dt><strong>mvtnorm</strong>
     <dd>Multivariate normal and t distributions. 
<br><dt><strong>ncdf</strong>
     <dd>Interface to Unidata netCDF data files. 
<br><dt><strong>ncomplete</strong>
     <dd>Functions to perform the regression depth method (RDM) to binary
regression to approximate the minimum number of observations that can be
removed such that the reduced data set has complete separation. 
<br><dt><strong>negenes</strong>
     <dd>Estimating the number of essential genes in a genome on the basis of
data from a random transposon mutagenesis experiment, through the use of
a Gibbs sampler. 
<br><dt><strong>netCDF</strong>
     <dd>Read data from netCDF files. 
<br><dt><strong>nlme</strong>
     <dd>Fit and compare Gaussian linear and nonlinear mixed-effects models. 
<em>Recommended</em>. 
<br><dt><strong>nlmeODE</strong>
     <dd>Combine the <strong>nlme</strong> and <strong>odesolve</strong> packages for
mixed-effects modelling using differential equations. 
<br><dt><strong>nlrq</strong>
     <dd>Nonlinear quantile regression. 
<br><dt><strong>nnet</strong>
     <dd>Software for single hidden layer perceptrons ("feed-forward neural
networks"), and for multinomial log-linear models.  Contained in the
<code>VR</code> bundle.  <em>Recommended</em>. 
<br><dt><strong>norm</strong>
     <dd>Analysis of multivariate normal datasets with missing values. 
<br><dt><strong>normalp</strong>
     <dd>A collection of utilities for normal of order p distributions
(General Error Distributions). 
<br><dt><strong>normix</strong>
     <dd>One-dimensional normal mixture models classes, for, e.g., density
estimation or clustering algorithms research and teaching; providing the
widely used Marron-Wand densities. 
<br><dt><strong>nortest</strong>
     <dd>Five omnibus tests for the composite hypothesis of normality. 
<br><dt><strong>noverlap</strong>
     <dd>Functions to perform the regression depth method (RDM) to binary
regression to approximate the amount of overlap, i.e., the minimal
number of observations that need to be removed such that the reduced
data set has no longer overlap. 
<br><dt><strong>npmc</strong>
     <dd>Nonparametric Multiple Comparisons:  provides simultaneous rank test
procedures for the one-way layout without presuming a certain
distribution. 
<br><dt><strong>nprq</strong>
     <dd>Nonparametric and sparse quantile regression methods. 
<br><dt><strong>odesolve</strong>
     <dd>An interface for the Ordinary Differential Equation (ODE) solver lsoda. 
ODEs are expressed as R functions. 
<br><dt><strong>orientlib</strong>
     <dd>Representations, conversions and display of orientation SO(3) data. 
<br><dt><strong>oz</strong>
     <dd>Functions for plotting Australia's coastline and state boundaries. 
<br><dt><strong>pamr</strong>
     <dd>Pam: Prediction Analysis for Microarrays. 
<br><dt><strong>panel</strong>
     <dd>Functions and datasets for fitting models to Panel data. 
<br><dt><strong>pastecs</strong>
     <dd>Package for Analysis of Space-Time Ecological Series. 
<br><dt><strong>pcurve</strong>
     <dd>Fits a principal curve to a numeric multivariate dataset in arbitrary
dimensions.  Produces diagnostic plots.  Also calculates Bray-Curtis and
other distance matrices and performs multi-dimensional scaling and
principal component analyses. 
<br><dt><strong>pear</strong>
     <dd>Periodic Autoregression Analysis. 
<br><dt><strong>permax</strong>
     <dd>Functions intended to facilitate certain basic analyses of DNA array
data, especially with regard to comparing expression levels between two
types of tissue. 
<br><dt><strong>pinktoe</strong>
     <dd>Converts S trees to <small>HTML</small>/Perl files for interactive tree traversal. 
<br><dt><strong>pixmap</strong>
     <dd>Functions for import, export, plotting and other manipulations of
bitmapped images. 
<br><dt><strong>pls.pcr</strong>
     <dd>Multivariate regression by PLS and PCR. 
<br><dt><strong>polspline</strong>
     <dd>Routines for the polynomial spline fitting routines hazard regression,
hazard estimation with flexible tails, logspline, lspec, polyclass, and
polymars, by C. Kooperberg and co-authors. 
<br><dt><strong>polynom</strong>
     <dd>A collection of functions to implement a class for univariate polynomial
manipulations. 
<br><dt><strong>pps</strong>
     <dd>Functions to select samples using PPS (probability proportional to size)
sampling, for stratified simple random sampling, and to compute joint
inclusion probabilities for Sampford's method of PPS sampling. 
<br><dt><strong>prabclus</strong>
     <dd>Distance based parametric bootstrap tests for clustering, mainly thought
for presence-absence data (clustering of species distribution maps). 
Jaccard and Kulczynski distance measures, clustering of MDS scores, and
nearest neighbor based noise detection. 
<br><dt><strong>princurve</strong>
     <dd>Fits a principal curve to a matrix of points in arbitrary dimension. 
<br><dt><strong>pspline</strong>
     <dd>Smoothing splines with penalties on order m derivatives. 
<br><dt><strong>psy</strong>
     <dd>Various procedures used in psychometry: Kappa, ICC, Cronbach alpha,
screeplot, PCA and related methods. 
<br><dt><strong>qtl</strong>
     <dd>Analysis of experimental crosses to identify QTLs. 
<br><dt><strong>quadprog</strong>
     <dd>For solving quadratic programming problems. 
<br><dt><strong>quantreg</strong>
     <dd>Quantile regression and related methods. 
<br><dt><strong>qvcalc</strong>
     <dd>Functions to compute quasi-variances and associated measures of
approximation error. 
<br><dt><strong>randomForest</strong>
     <dd>Breiman's random forest classifier. 
<br><dt><strong>relimp</strong>
     <dd>Functions to facilitate inference on the relative importance of
predictors in a linear or generalized linear model. 
<br><dt><strong>rgenoud</strong>
     <dd>R version of GENetic Optimization Using Derivatives. 
<br><dt><strong>rimage</strong>
     <dd>Functions for image processing, including Sobel filter, rank filters,
fft, histogram equalization, and reading <small>JPEG</small> files. 
<br><dt><strong>rmeta</strong>
     <dd>Functions for simple fixed and random effects meta-analysis for
two-sample comparison of binary outcomes. 
<br><dt><strong>rpart</strong>
     <dd>Recursive PARTitioning and regression trees.  <em>Recommended</em>. 
<br><dt><strong>rpvm</strong>
     <dd>R interface to PVM (Parallel Virtual Machine).  Provides interface to
PVM APIs, and examples and documentation for its use. 
<br><dt><strong>rqmcmb2</strong>
     <dd>Markov chain marginal bootstrap for quantile regression. 
<br><dt><strong>rsprng</strong>
     <dd>Provides interface to SPRNG (Scalable Parallel Random Number Generators)
APIs, and examples and documentation for its use. 
<br><dt><strong>sampfling</strong>
     <dd>Implements a modified version of the Sampford sampling algorithm.  Given
a quantity assigned to each unit in the population, samples are drawn
with probability proportional to te product of the quantities of the
units included in the sample. 
<br><dt><strong>sca</strong>
     <dd>Simple Component Analysis. 
<br><dt><strong>scatterplot3d</strong>
     <dd>Plots a three dimensional (3D) point cloud perspectively. 
<br><dt><strong>seacarb</strong>
     <dd>Calculates parameters of the seawater carbonate system. 
<br><dt><strong>seao</strong>
     <dd>Simple Evolutionary Algorithm Optimization. 
<br><dt><strong>seao.gui</strong>
     <dd>Simple Evolutionary Algorithm Optimization: graphical user interface. 
<br><dt><strong>segmented</strong>
     <dd>Functions to estimate break-points of segmented relationships in
regression models (GLMs). 
<br><dt><strong>sem</strong>
     <dd>Functions for fitting general linear Structural Equation Models (with
observed and unobserved variables) by the method of maximum likelihood
using the RAM approach. 
<br><dt><strong>serialize</strong>
     <dd>Simple interfce for serializing to connections. 
<br><dt><strong>session</strong>
     <dd>Functions for interacting with, saving and restoring R sessions. 
<br><dt><strong>sgeostat</strong>
     <dd>An object-oriented framework for geostatistical modeling. 
<br><dt><strong>shapefiles</strong>
     <dd>Functions to read and write ESRI shapefiles. 
<br><dt><strong>shapes</strong>
     <dd>Routines for the statistical analysis of shapes, including procrustes
analysis, displaying shapes and principal components, testing for mean
shape difference, thin-plate spline transformation grids and edge
superimposition methods. 
<br><dt><strong>simpleboot</strong>
     <dd>Simple bootstrap routines. 
<br><dt><strong>sm</strong>
     <dd>Software linked to the book "Applied Smoothing Techniques for Data
Analysis:  The Kernel Approach with <small>S-PLUS</small> Illustrations" by
A. W. Bowman and A. Azzalini (1997), Oxford University Press. 
<br><dt><strong>sma</strong>
     <dd>Functions for exploratory (statistical) microarray analysis. 
<br><dt><strong>smoothSurv</strong>
     <dd>Survival regression with smoothed error distribution. 
<br><dt><strong>sn</strong>
     <dd>Functions for manipulating skew-normal probability distributions and for
fitting them to data, in the scalar and the multivariate case. 
<br><dt><strong>sna</strong>
     <dd>A range of tools for social network analysis, including node and
graph-level indices, structural distance and covariance methods,
structural equivalence detection, p* modeling, and network
visualization. 
<br><dt><strong>snow</strong>
     <dd>Simple Network of Workstations: support for simple parallel computing in
R. 
<br><dt><strong>som</strong>
     <dd>Self-Organizing Maps (with application in gene clustering). 
<br><dt><strong>sound</strong>
     <dd>A sound interface for R: Basic functions for dealing with <code>.wav</code>
files and sound samples. 
<br><dt><strong>spatial</strong>
     <dd>Functions for kriging and point pattern analysis from "Modern Applied
Statistics with S" by W. Venables and B. Ripley.  Contained in the
<code>VR</code> bundle.  <em>Recommended</em>. 
<br><dt><strong>spatstat</strong>
     <dd>Data analysis and modelling of two-dimensional point patterns, including
multitype points and spatial covariates. 
<br><dt><strong>spdep</strong>
     <dd>A collection of functions to create spatial weights matrix objects from
polygon contiguities, from point patterns by distance and tesselations,
for summarising these objects, and for permitting their use in spatial
data analysis; a collection of tests for spatial autocorrelation,
including global Moran's I and Geary's C, local Moran's I, saddlepoint
approximations for global and local Moran's I; and functions for
estimating spatial simultaneous autoregressive (SAR) models.  (Was
formerly the three packages: <strong>spweights</strong>, <strong>sptests</strong>, and
<strong>spsarlm</strong>.) 
<br><dt><strong>splancs</strong>
     <dd>Spatial and space-time point pattern analysis functions. 
<br><dt><strong>statmod</strong>
     <dd>Miscellaneous biostatistical modelling functions. 
<br><dt><strong>strucchange</strong>
     <dd>Various tests on structural change in linear regression models. 
<br><dt><strong>subselect</strong>
     <dd>A collection of functions which assess the quality of variable subsets
as surrogates for a full data set, and search for subsets which are
optimal under various criteria. 
<br><dt><strong>survey</strong>
     <dd>Summary statistics, generalized linear models, and general maximum
likelihood estimation for stratified, cluster-sampled, unequally
weighted survey samples. 
<br><dt><strong>survival</strong>
     <dd>Functions for survival analysis, including penalised likelihood. 
<em>Recommended</em>. 
<br><dt><strong>survrec</strong>
     <dd>Survival analysis for recurrent event data. 
<br><dt><strong>systemfit</strong>
     <dd>Contains functions for fitting simultaneous systems of equations using
Ordinary Least Sqaures (OLS), Two-Stage Least Squares (2SLS), and
Three-Stage Least Squares (3SLS). 
<br><dt><strong>tapiR</strong>
     <dd>Tools for accessing (UK) parliamentary information in R. 
<br><dt><strong>tensor</strong>
     <dd>Tensor product of arrays. 
<br><dt><strong>tkrplot</strong>
     <dd>Simple mechanism for placing R graphics in a Tk widget. 
<br><dt><strong>tree</strong>
     <dd>Classification and regression trees. 
<br><dt><strong>tripack</strong>
     <dd>A constrained two-dimensional Delaunay triangulation package. 
<br><dt><strong>tseries</strong>
     <dd>Package for time series analysis with emphasis on non-linear modelling. 
<br><dt><strong>udunits</strong>
     <dd>Interface to Unidata's routines to convert units. 
<br><dt><strong>vardiag</strong>
     <dd>Interactive variogram diagnostics. 
<br><dt><strong>vcd</strong>
     <dd>Functions and data sets based on the book "Visualizing Categorical
Data" by Michael Friendly. 
<br><dt><strong>vegan</strong>
     <dd>Various help functions for vegetation scientists and community
ecologists. 
<br><dt><strong>waveslim</strong>
     <dd>Basic wavelet routines for time series analysis. 
<br><dt><strong>wavethresh</strong>
     <dd>Software to perform 1-d and 2-d wavelet statistics and transforms. 
<br><dt><strong>wle</strong>
     <dd>Robust statistical inference via a weighted likelihood approach. 
<br><dt><strong>xgobi</strong>
     <dd>Interface to the XGobi and XGvis programs for graphical data analysis. 
<br><dt><strong>xtable</strong>
     <dd>Export data to LaTeX and <small>HTML</small> tables. 
</dl>

<p>See <small>CRAN</small> <code>src/contrib/PACKAGES</code> for more information.

   <p>There is also a <small>CRAN</small> <code>src/contrib/Devel</code> directory which
contains packages still "under development" or depending on features
only present in the current development versions of R.  Volunteers are
invited to give these a try, of course.  This area of <small>CRAN</small> currently
contains

     <dl>
<dt><strong>Dopt</strong>
     <dd>Finding D-optimal experimental designs.

     <br><dt><strong>EMV</strong>
     <dd>Estimation of missing values in a matrix by a k-th nearest
neighboors algorithm.

     <br><dt><strong>GLMMGibbs</strong>
     <dd>Generalised Linear Mixed Models by Gibbs sampling.

     <br><dt><strong>RPgSQL</strong>
     <dd>Provides methods for accessing data stored in PostgreSQL tables.

     <br><dt><strong>Rmpi</strong>
     <dd>An interface (wrapper) to MPI (Message-Passing Interface) APIs.  It also
provides interactive R slave functionalities to make MPI programming
easier in R than in C(++) or FORTRAN.

     <br><dt><strong>dseplus</strong>
     <dd>Extensions to <strong>dse</strong>, the Dynamic Systems Estimation multivariate
time series package.  Contains PADI, juice and monitoring extensions.

     <br><dt><strong>ensemble</strong>
     <dd>Ensembles of tree classifiers.

     <br><dt><strong>gllm</strong>
     <dd>Routines for log-linear models of incomplete contingency tables,
including some latent class models via EM and Fisher scoring approaches.

     <br><dt><strong>meanscore</strong>
     <dd>Mean Score method for missing covariate data in logistic regression
models.

     <br><dt><strong>runStat</strong>
     <dd>Running median and mean.

     <br><dt><strong>twostage</strong>
     <dd>Functions for optimal design of two-stage-studies using the Mean Score
method.

     <br><dt><strong>write.snns</strong>
     <dd>Function for writing a <small>SNNS</small> pattern file from a data frame or
matrix. 
</dl>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Add-on%20packages%20from%20Omegahat">Add-on packages from Omegahat</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Add-on%20packages%20from%20BioConductor">Add-on packages from BioConductor</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Add-on%20packages%20from%20CRAN">Add-on packages from CRAN</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Which%20add-on%20packages%20exist%20for%20R%3f">Which add-on packages exist for R?</a>
<br>
</div>

<h3 class="subsection">5.1.3 Add-on packages from Omegahat</h4>

<p>The <code>src/contrib/Omegahat</code> Directory of a CRAN site contains yet
unreleased packages from the <a href="http://www.omegahat.org/">Omegahat Project for Statistical Computing</a>.  Currently, there are

     <dl>
<dt><strong>CORBA</strong>
     <dd>Dynamic CORBA client/server facilities for R.  Connects to other
CORBA-aware applications developed in arbitrary languages, on different
machines and allows R functionality to be exported in the same way to
other applications. 
<br><dt><strong>OOP</strong>
     <dd>OOP style classes and methods for R and <small>S-PLUS</small>.  Object references and
class-based method definition are supported in the style of languages
such as Java and C++. 
<br><dt><strong>REmbeddedPostgres</strong>
     <dd>Allows R functions and objects to be used to implement SQL functions --
per-record, aggregate and trigger functions. 
<br><dt><strong>REventLoop</strong>
     <dd>An abstract event loop mechanism that is toolkit independent and can be
used to to replace the R event loop. 
<br><dt><strong>RGdkPixbuf</strong>
     <dd>S language functions to access the facilities in the GdkPixbuf library
for manipulating images. 
<br><dt><strong>RGnumeric</strong>
     <dd>A plugin for the Gnumeric spreadsheet that allows R functions to be
called from cells within the sheet, automatic recalculation, etc. 
<br><dt><strong>RGtk</strong>
     <dd>Facilities in the S language for programming graphical interfaces using
Gtk, the Gnome GUI toolkit. 
<br><dt><strong>RGtkBindingGenerator</strong>
     <dd>A meta-package which generates C and R code to provide bindings to a
Gtk-based library. 
<br><dt><strong>RGtkExtra</strong>
     <dd>A collection of S functions that provide an interface to the widgets in
the gtk+extra library such as the GtkSheet data-grid display, icon list,
file list and directory tree. 
<br><dt><strong>RGtkGlade</strong>
     <dd>S language bindings providing an interface to Glade, the interactive
Gnome GUI creator. 
<br><dt><strong>RGtkHTML</strong>
     <dd>A collection of S functions that provide an interface to creating and
controlling an <small>HTML</small> widget which can be used to display <small>HTML</small>
documents from files or content generated dynamically in S. 
<br><dt><strong>RGtkViewers</strong>
     <dd>A collection of tools for viewing different S objects, databases, class
and widget hierarchies, S source file contents, etc. 
<br><dt><strong>RJavaDevice</strong>
     <dd>A graphics device for R that uses Java components and graphics. 
<small>API</small>s. 
<br><dt><strong>RObjectTables</strong>
     <dd>The C and S code allows one to define R objects to be used as elements
of the search path with their own semantics and facilities for reading
and writing variables.  The objects implement a simple interface via R
functions (either methods or closures) and can access external data,
e.g., in other applications, languages, formats, <small class="dots">...</small>
<br><dt><strong>RSMethods</strong>
     <dd>An implementation of S version 4 methods and classes for R, consistent
with the basic material in "Programming with Data" by John
M. Chambers, 1998, Springer NY. 
<br><dt><strong>RSPerl</strong>
     <dd>An interface from R to an embedded, persistent Perl interpreter,
allowing one to call arbitrary Perl subroutines, classes and methods. 
<br><dt><strong>RSPython</strong>
     <dd>Allows Python programs to invoke S functions, methods, etc., and S code
to call Python functionality. 
<br><dt><strong>RXLisp</strong>
     <dd>An interface to call XLisp-Stat functions from within R. 
<br><dt><strong>SASXML</strong>
     <dd>Example for reading <small>XML</small> files in SAS 8.2 manner. 
<br><dt><strong>SJava</strong>
     <dd>An interface from R to Java to create and call Java objects and
methods. 
<br><dt><strong>SLanguage</strong>
     <dd>Functions and C support utilities to support S language programming
that can work in both R and <small>S-PLUS</small>. 
<br><dt><strong>SNetscape</strong>
     <dd>Plugin for Netscape and JavaScript. 
<br><dt><strong>SWinRegistry</strong>
     <dd>Provides access from within R to read and write the Windows registry. 
<br><dt><strong>SWinTypeLibs</strong>
     <dd>Provides ways to extract type information from type libraries and/or
DCOM objects that describes the methods, properties, etc. of an
interface. 
<br><dt><strong>SXalan</strong>
     <dd>Process <small>XML</small> documents using <small>XSL</small> functions implemented in R and
dynamically substituting output from R. 
<br><dt><strong>Slcc</strong>
     <dd>Parses C source code, allowing one to analyze and automatically generate
interfaces from S to that code, including the table of S-accessible
native symbols, parameter count and type information, S constructors
from C objects, call graphs, etc. 
<br><dt><strong>Sxslt</strong>
     <dd>An extension module for libxslt, the <small>XML</small>-<small>XSL</small> document translator,
that allows <small>XSL</small> functions to be implemented via R functions. 
</dl>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Add-on%20packages%20from%20BioConductor">Add-on packages from BioConductor</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Other%20add-on%20packages">Other add-on packages</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Add-on%20packages%20from%20Omegahat">Add-on packages from Omegahat</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Which%20add-on%20packages%20exist%20for%20R%3f">Which add-on packages exist for R?</a>
<br>
</div>

<h3 class="subsection">5.1.4 Add-on packages from BioConductor</h4>

<p>The <a href="http://www.bioconductor.org">Bioconductor Project</a> produces an
open source software framework that will assist biologists and
statisticians working in bioinformatics, with primary emphasis on
inference using DNA microarrays.  The following R packages are contained
in the current release of BioConductor, with more packages under
development.

     <dl>
<dt><strong>AnnBuilder</strong>
     <dd>Assemble and process genomic annotation data, from databases such as
GenBank, the Gene Ontology Consortium, LocusLink, UniGene, the UCSC
Human Genome Project. 
<br><dt><strong>Biobase</strong>
     <dd>Object-oriented representation and manipulation of genomic data (S4
class structure). 
<br><dt><strong>DynDoc</strong>
     <dd>Functionality to create and interact with dynamic documents, vignettes,
and other navigable documents. 
<br><dt><strong>MAGEML</strong>
     <dd>Functionality to handle MAGEML documents. 
<br><dt><strong>RBGL</strong>
     <dd>An interface between the graph package and the Boost graph libraries,
allowing for fast manipulation of graph objects in R. 
<br><dt><strong>ROC</strong>
     <dd>Receiver Operating Characteristic (ROC) approach for identifying genes
that are differentially expressed in two types of samples. 
<br><dt><strong>RdbiPgSQL</strong>
     <dd>Methods for accessing data stored in PostgreSQL tables. 
<br><dt><strong>Rgraphviz</strong>
     <dd>An interface with Graphviz for plotting graph objects in R. 
<br><dt><strong>Ruuid</strong>
     <dd>Creates Universally Unique ID values (UUIDs) in R. 
<br><dt><strong>SAGElyzer</strong>
     <dd>Locates genes based on SAGE tags. 
<br><dt><strong>SNPtools</strong>
     <dd>Rudimentary structures for SNP data. 
<br><dt><strong>affy</strong>
     <dd>Methods for Affymetrix Oligonucleotide Arrays. 
<br><dt><strong>affyPLM</strong>
     <dd>For fitting Probe Level Models. 
<br><dt><strong>affycomp</strong>
     <dd>Graphics toolbox for assessment of Affymetrix expression measures. 
<br><dt><strong>affydata</strong>
     <dd>Affymetrix data for demonstration purposes. 
<br><dt><strong>annaffy</strong>
     <dd>Functions for handling data from Bioconductor Affymetrix annotation data
packages. 
<br><dt><strong>annotate</strong>
     <dd>Associate experimental data in real time to biological metadata from web
databases such as GenBank, LocusLink and PubMed.  Process and store
query results.  Generate <small>HTML</small> reports of analyses. 
<br><dt><strong>ctc</strong>
     <dd>Tools to export and import Tree and Cluster to other programs. 
<br><dt><strong>daMA</strong>
     <dd>Functions for the efficient design of factorial two-color microarray
experiments and for the statistical analysis of factorial microarray
data. 
<br><dt><strong>edd</strong>
     <dd>Expression density diagnostics: graphical methods and pattern
recognition algorithms for distribution shape classification. 
<br><dt><strong>externalVector</strong>
     <dd>Basic class definitions and generics for external pointer based vector
objects for R. 
<br><dt><strong>factDesign</strong>
     <dd>A set of tools for analyzing data from factorial designed micraorray
experiments.  The functions can be used to evaluate appropriate tests of
contrast and perform single outlier detection. 
<br><dt><strong>gcrma</strong>
     <dd>Background adjustment using sequence information. 
<br><dt><strong>genefilter</strong>
     <dd>Tools for sequentially filtering genes using a wide variety of filtering
functions.  Example of filters include: number of missing value,
coefficient of variation of expression measures, ANOVA p-value,
Cox model p-values.  Sequential application of filtering
functions to genes. 
<br><dt><strong>geneplotter</strong>
     <dd>Graphical tools for genomic data, for example for plotting expression
data along a chromosome or producing color images of expression data
matrices. 
<br><dt><strong>globaltest</strong>
     <dd>Testing globally whether a group of genes is significantly related to
some clinical variable of interest. 
<br><dt><strong>gpls</strong>
     <dd>Classification using generalized partial least squares for two-group and
multi-group classification. 
<br><dt><strong>graph</strong>
     <dd>Classes and tools for creating and manipulating graphs within R. 
<br><dt><strong>hexbin</strong>
     <dd>Binning functions, in particular hexagonal bins for graphing. 
<br><dt><strong>limma</strong>
     <dd>Linear models for microarray data. 
<br><dt><strong>makecdfenv</strong>
     <dd>Two functions.  One reads a Affymetrix chip description file (CDF) and
creates a hash table environment containing the location/probe set
membership mapping.  The other creates a package that automatically loads
that environment. 
<br><dt><strong>marrayClasses</strong>
     <dd>Class definitions for pre-normalized and normalized cDNA microarray
data.  Basic methods for accessing/replacing, printing, and subsetting. 
<br><dt><strong>marrayInput</strong>
     <dd>Functions for reading microarray data into R from different image
analysis output files, and probe and target description files.  Widgets
are supplied to facilitate and automate data input and the creation of
microarray specific R objects for storing these data. 
<br><dt><strong>marrayNorm</strong>
     <dd>Functions for location and scale normalization procedures based on
robust local regression. 
<br><dt><strong>marrayPlots</strong>
     <dd>Functions for diagnostic plots for pre- and post-normalization cDNA
microarray intensity data: boxplots, scatter-plots, color images. 
<br><dt><strong>marrayTools</strong>
     <dd>Miscellaneous functions used in the functional genomics core facility in
UCB and UCSF. 
<br><dt><strong>matchprobes</strong>
     <dd>ools for sequence matching of probes on arrays. 
<br><dt><strong>multtest</strong>
     <dd>Multiple testing procedures for controlling the family-wise error rate
(FWER) and the false discovery rate (FDR).  Tests can be based on
t- or F-statistics for one- and two-factor designs, and
permutation procedures are available to estimate adjusted
p-values. 
<br><dt><strong>ontoTools</strong>
     <dd>Graphs and sparse matrices for working with ontologies. 
<br><dt><strong>pamr</strong>
     <dd>Pam: prediction analysis for microarrays. 
<br><dt><strong>reposTools</strong>
     <dd>Tools for dealing with file repositories and allow users to easily
install, update, and distribute packages, vignettes, and other files. 
<br><dt><strong>rhdf5</strong>
     <dd>Storage and retrieval of large datasets using the HDF5 library and file
format. 
<br><dt><strong>siggenes</strong>
     <dd>Identifying differentially expressed genes and estimating the False
Discovery Rate (FDR) with both the Significance Analysis of Microarrays
(SAM) and the Empirical Bayes Analyses of Microarrays (EBAM). 
<br><dt><strong>splicegear</strong>
     <dd>A set of tools to work with alternative splicing. 
<br><dt><strong>tkWidgets</strong>
     <dd>Widgets in Tcl/Tk that provide functionality for Bioconductor packages. 
<br><dt><strong>vsn</strong>
     <dd>Calibration and variance stabilizing transformations for both Affymetrix
and cDNA array data. 
<br><dt><strong>widgetTools</strong>
     <dd>Tools for creating Tcl/Tk widgets, i.e., small-scale graphical user
interfaces. 
</dl>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Other%20add-on%20packages">Other add-on packages</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Add-on%20packages%20from%20BioConductor">Add-on packages from BioConductor</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Which%20add-on%20packages%20exist%20for%20R%3f">Which add-on packages exist for R?</a>
<br>
</div>

<h3 class="subsection">5.1.5 Other add-on packages</h4>

<a href="mailto:jlindsey@luc.ac.be">Jim Lindsey</a> has written a collection of R
packages for nonlinear regression and repeated measurements, consisting
of <strong>event</strong> (event history procedures and models), <strong>gnlm</strong>
(generalized nonlinear regression models), <strong>growth</strong> (multivariate
normal and elliptically-contoured repeated measurements models),
<strong>repeated</strong> (non-normal repeated measurements models),
<strong>rmutil</strong> (utilities for nonlinear regression and repeated
measurements), and <strong>stable</strong> (probability functions and
generalized regression models for stable distributions).  All analyses
in the new edition of his book "Models for Repeated Measurements"
(1999, Oxford University Press) were carried out using these packages. 
Jim has also started <strong>dna</strong>, a package with procedures for the
analysis of DNA sequences.  Jim's packages can be obtained from
<a href="http://www.luc.ac.be/~jlindsey/rcode.html">http://www.luc.ac.be/~jlindsey/rcode.html</a>.

   <p>More code has been posted to the R-help mailing list, and can be
obtained from the mailing list archive.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20add-on%20packages%20be%20installed%3f">How can add-on packages be installed?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20add-on%20packages%20be%20used%3f">How can add-on packages be used?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Which%20add-on%20packages%20exist%20for%20R%3f">Which add-on packages exist for R?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Add-On%20Packages">R Add-On Packages</a>
<br>
</div>

<h3 class="section">5.2 How can add-on packages be installed?</h3>

<p>(Unix only.)  The add-on packages on <small>CRAN</small> come as gzipped tar
files named <code></code><var>pkg</var><code>_</code><var>version</var><code>.tar.gz</code>, which may in fact be
"bundles" containing more than one package.  Provided that
<code>tar</code> and <code>gzip</code> are available on your system, type

<pre class="example">     $ R CMD INSTALL /path/to/<var>pkg</var>_<var>version</var>.tar.gz
     </pre>

<p>at the shell prompt to install to the library tree rooted at the first
directory given in <code>R_LIBS</code> (see below) if this is set and non-null,
and to the default library (the <code>library</code> subdirectory of
<code>R_HOME</code>) otherwise.  (Versions of R prior to 1.3.0 installed
to the default library by default.)

   <p>To install to another tree (e.g., your private one), use

<pre class="example">     $ R CMD INSTALL -l <var>lib</var> /path/to/<var>pkg</var>_<var>version</var>.tar.gz
     </pre>

<p>where <var>lib</var> gives the path to the library tree to install to.

   <p>Even more conveniently, you can install and automatically update
packages from within R if you have access to <small>CRAN</small>.  See the
help page for <code>CRAN.packages()</code> for more information.

   <p>You can use several library trees of add-on packages.  The easiest way
to tell R to use these is via the environment variable <code>R_LIBS</code>
which should be a colon-separated list of directories at which R library
trees are rooted.  You do not have to specify the default tree in
<code>R_LIBS</code>.  E.g., to use a private tree in <code>$HOME/lib/R</code> and a
public site-wide tree in <code>/usr/local/lib/R-contrib</code>, put

<pre class="example">     R_LIBS="$HOME/lib/R:/usr/local/lib/R-contrib"; export R_LIBS
     </pre>

<p>into your (Bourne) shell profile or even preferably, add the line

<pre class="example">     R_LIBS="$HOME/lib/R:/usr/local/lib/R-contrib"
     </pre>

<p>your <code>~/.Renviron</code> file.  (Note that no <code>export</code> statement is
needed or allowed in this file; see the on-line help for <code>Startup</code>
for more information.)

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20add-on%20packages%20be%20used%3f">How can add-on packages be used?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20add-on%20packages%20be%20removed%3f">How can add-on packages be removed?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20add-on%20packages%20be%20installed%3f">How can add-on packages be installed?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Add-On%20Packages">R Add-On Packages</a>
<br>
</div>

<h3 class="section">5.3 How can add-on packages be used?</h3>

<p>To find out which additional packages are available on your system, type

<pre class="example">     library()
     </pre>

<p>at the R prompt.

   <p>This produces something like

<pre class="smallexample">     Packages in `/home/me/lib/R':
     
     mystuff       My own R functions, nicely packaged but not documented
     
     Packages in `/usr/local/lib/R/library':
     
     KernSmooth    Functions for kernel smoothing for Wand &amp; Jones (1995)
     MASS          Main Library of Venables and Ripley's MASS
     base          The R base package
     boot          Bootstrap R (S-Plus) Functions (Canty)
     class         Functions for classification
     cluster       Functions for clustering (by Rousseeuw et al.)
     ctest         Classical Tests
     eda           Exploratory Data Analysis
     foreign       Read data stored by Minitab, S, SAS, SPSS, Stata, ...
     grid          The Grid Graphics Package
     lattice       Lattice Graphics
     lqs           Resistant Regression and Covariance Estimation
     methods       Formal Methods and Classes
     mle           Maximum likelihood estimation
     mgcv          Multiple smoothing parameter estimation and GAMs by GCV
     modreg        Modern Regression: Smoothing and Local Methods
     mva           Classical Multivariate Analysis
     nlme          Linear and nonlinear mixed effects models
     nls           Nonlinear regression
     nnet          Feed-forward neural networks and multinomial log-linear
                   models
     rpart         Recursive partitioning
     spatial       functions for kriging and point pattern analysis
     splines       Regression Spline Functions and Classes
     stepfun       Step Functions, including Empirical Distributions
     survival      Survival analysis, including penalised likelihood
     tcltk         Tcl/Tk Interface
     tools         Tools for Package Development and Administration
     ts            Time series functions
     </pre>

   <p>You can "load" the installed package <var>pkg</var> by

<pre class="example">     library(<var>pkg</var>)
     </pre>

   <p>You can then find out which functions it provides by typing one of

<pre class="example">     library(help = <var>pkg</var>)
     help(package = <var>pkg</var>)
     </pre>

   <p>You can unload the loaded package <var>pkg</var> by

<pre class="example">     detach("package:<var>pkg</var>")
     </pre>

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20add-on%20packages%20be%20removed%3f">How can add-on packages be removed?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20create%20an%20R%20package%3f">How can I create an R package?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20add-on%20packages%20be%20used%3f">How can add-on packages be used?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Add-On%20Packages">R Add-On Packages</a>
<br>
</div>

<h3 class="section">5.4 How can add-on packages be removed?</h3>

<p>Use

<pre class="example">     $ R CMD REMOVE <var>pkg_1</var> ... <var>pkg_n</var>
     </pre>

<p>to remove the packages <var>pkg_1</var>, <small class="dots">...</small>, <var>pkg_n</var> from the
library tree rooted at the first directory given in <code>R_LIBS</code> if this
is set and non-null, and from the default library otherwise.  (Versions
of R prior to 1.3.0 removed from the default library by default.)

   <p>To remove from library <var>lib</var>, do

<pre class="example">     $ R CMD REMOVE -l <var>lib</var> <var>pkg_1</var> ... <var>pkg_n</var>
     </pre>

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20create%20an%20R%20package%3f">How can I create an R package?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20contribute%20to%20R%3f">How can I contribute to R?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20add-on%20packages%20be%20removed%3f">How can add-on packages be removed?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Add-On%20Packages">R Add-On Packages</a>
<br>
</div>

<h3 class="section">5.5 How can I create an R package?</h3>

<p>A package consists of a subdirectory containing the files
<code>DESCRIPTION</code> and <code>INDEX</code>, and the subdirectories <code>R</code>,
<code>data</code>, <code>demo</code>, <code>exec</code>, <code>inst</code>, <code>man</code>,
<code>src</code>, and <code>tests</code> (some of which can be missing).  Optionally
the package can also contain script files <code>configure</code> and
<code>cleanup</code> which are executed before and after installation.

   <p>See section "Creating R packages" in <cite>Writing R Extensions</cite>, for
details. 
This manual is included in the R distribution, see <a href="#What%20documentation%20exists%20for%20R%3f">What documentation exists for R?</a>, and gives information on package structure, the
configure and cleanup mechanisms, and on automated package checking and
building.

   <p>R version 1.3.0 has added the function <code>package.skeleton()</code> which
will set up directories, save data and code, and create skeleton help
files for a set of R functions and datasets.

   <p>See <a href="#What%20is%20CRAN%3f">What is CRAN?</a>, for information on uploading a package to CRAN.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20contribute%20to%20R%3f">How can I contribute to R?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20I%20create%20an%20R%20package%3f">How can I create an R package?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Add-On%20Packages">R Add-On Packages</a>
<br>
</div>

<h3 class="section">5.6 How can I contribute to R?</h3>

<p>R is in active development and there is always a risk of bugs creeping
in.  Also, the developers do not have access to all possible machines
capable of running R.  So, simply using it and communicating problems is
certainly of great value.

   <p>One place where functionality is still missing is the modeling software
as described in "Statistical Models in S" (see <a href="#What%20is%20S%3f">What is S?</a>);
Generalized Additive Models (see <a href="#Are%20GAMs%20implemented%20in%20R%3f">Are GAMs implemented in R?</a>) and
some of the nonlinear modeling code are not there yet.

   <p>The <a href="http://developer.R-project.org/">R Developer Page</a> acts as an
intermediate repository for more or less finalized ideas and plans for
the R statistical system.  It contains (pointers to) TODO lists, RFCs,
various other writeups, ideas lists, and CVS miscellanea.

   <p>Many (more) of the packages available at the Statlib S Repository might
be worth porting to R.

   <p>If you are interested in working on any of these projects, please notify
<a href="mailto:Kurt.Hornik@R-project.org">Kurt Hornik</a>.

<div class="node">
<p><hr>
Node:&nbsp;<a name="R%20and%20Emacs">R and Emacs</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#R%20Miscellanea">R Miscellanea</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20Add-On%20Packages">R Add-On Packages</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>
<br>
</div>

<h2 class="chapter">6 R and Emacs</h2>

<ul class="menu">
<li><a accesskey="1" href="#Is%20there%20Emacs%20support%20for%20R%3f">Is there Emacs support for R?</a>: 
<li><a accesskey="2" href="#Should%20I%20run%20R%20from%20within%20Emacs%3f">Should I run R from within Emacs?</a>: 
<li><a accesskey="3" href="#Debugging%20R%20from%20within%20Emacs">Debugging R from within Emacs</a>: 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Is%20there%20Emacs%20support%20for%20R%3f">Is there Emacs support for R?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Should%20I%20run%20R%20from%20within%20Emacs%3f">Should I run R from within Emacs?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20and%20Emacs">R and Emacs</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20and%20Emacs">R and Emacs</a>
<br>
</div>

<h3 class="section">6.1 Is there Emacs support for R?</h3>

<p>There is an Emacs package called <small>ESS</small> ("Emacs Speaks
Statistics") which provides a standard interface between statistical
programs and statistical processes.  It is intended to provide
assistance for interactive statistical programming and data analysis. 
Languages supported include: S dialects (S 3/4, <small>S-PLUS</small> 3.x/4.x/5.x,
and R), LispStat dialects (XLispStat, ViSta) and SAS.  Stata and SPSS
dialect (SPSS, PSPP) support is being examined for possible future
implementation

   <p><small>ESS</small> grew out of the need for bug fixes and extensions to
S-mode 4.8 (which was a <small>GNU</small> Emacs interface to S/<small>S-PLUS</small>
version 3 only).  The current set of developers desired support for
XEmacs, R, S4, and MS Windows.  In addition, with new modes being
developed for R, Stata, and SAS, it was felt that a unifying interface
and framework for the user interface would benefit both the user and the
developer, by helping both groups conform to standard Emacs usage.  The
end result is an increase in efficiency for statistical programming and
data analysis, over the usual tools.

   <p>R support contains code for editing R source code (syntactic indentation
and highlighting of source code, partial evaluations of code, loading
and error-checking of code, and source code revision maintenance) and
documentation (syntactic indentation and highlighting of source code,
sending examples to running <small>ESS</small> process, and previewing),
interacting with an inferior R process from within Emacs (command-line
editing, searchable command history, command-line completion of R object
and file names, quick access to object and search lists, transcript
recording, and an interface to the help system), and transcript
manipulation (recording and saving transcript files, manipulating and
editing saved transcripts, and re-evaluating commands from transcript
files).

   <p>The latest stable version of <small>ESS</small> are available via <small>CRAN</small> or
the <a href="http://ESS.R-project.org/">ESS web page</a>.  The <small>HTML</small> version
of the documentation can be found at <a href="http://stat.ethz.ch/ESS/">http://stat.ethz.ch/ESS/</a>.

   <p><small>ESS</small> comes with detailed installation instructions.

   <p>For help with <small>ESS</small>, send email to
<a href="mailto:ESS-help@stat.ethz.ch">ESS-help@stat.ethz.ch</a>.

   <p>Please send bug reports and suggestions on <small>ESS</small> to
<a href="mailto:ESS-bugs@stat.math.ethz.ch">ESS-bugs@stat.math.ethz.ch</a>.  The easiest way to do this from is
within Emacs by typing <kbd>M-x ess-submit-bug-report</kbd> or using the
[ESS] or [iESS] pulldown menus.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Should%20I%20run%20R%20from%20within%20Emacs%3f">Should I run R from within Emacs?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Debugging%20R%20from%20within%20Emacs">Debugging R from within Emacs</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Is%20there%20Emacs%20support%20for%20R%3f">Is there Emacs support for R?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20and%20Emacs">R and Emacs</a>
<br>
</div>

<h3 class="section">6.2 Should I run R from within Emacs?</h3>

<p>Yes, <em>definitely</em>.  Inferior R mode provides a readline/history
mechanism, object name completion, and syntax-based highlighting of the
interaction buffer using Font Lock mode, as well as a very convenient
interface to the R help system.

   <p>Of course, it also integrates nicely with the mechanisms for editing R
source using Emacs.  One can write code in one Emacs buffer and send
whole or parts of it for execution to R; this is helpful for both data
analysis and programming.  One can also seamlessly integrate with a
revision control system, in order to maintain a log of changes in your
programs and data, as well as to allow for the retrieval of past
versions of the code.

   <p>In addition, it allows you to keep a record of your session, which can
also be used for error recovery through the use of the transcript mode.

   <p>To specify command line arguments for the inferior R process, use
<kbd>C-u M-x R</kbd> for starting R.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Debugging%20R%20from%20within%20Emacs">Debugging R from within Emacs</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Should%20I%20run%20R%20from%20within%20Emacs%3f">Should I run R from within Emacs?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20and%20Emacs">R and Emacs</a>
<br>
</div>

<h3 class="section">6.3 Debugging R from within Emacs</h3>

<p>To debug R "from within Emacs", there are several possibilities.  To
use the Emacs GUD (Grand Unified Debugger) library with the recommended
debugger GDB, type <kbd>M-x gdb</kbd> and give the path to the R
<em>binary</em> as argument.  At the <code>gdb</code> prompt, set
<code>R_HOME</code> and other environment variables as needed (using e.g. 
<kbd>set env R_HOME /path/to/R/</kbd>, but see also below), and start the
binary with the desired arguments (e.g., <kbd>run --quiet</kbd>).

   <p>If you have <small>ESS</small>, you can do <kbd>C-u M-x R &lt;RET&gt; - d
&lt;SPC&gt; g d b &lt;RET&gt;</kbd> to start an inferior R process with arguments
<code>-d gdb</code>.

   <p>A third option is to start an inferior R process via <small>ESS</small>
(<kbd>M-x R</kbd>) and then start GUD (<kbd>M-x gdb</kbd>) giving the R binary
(using its full path name) as the program to debug.  Use the program
<code>ps</code> to find the process number of the currently running R
process then use the <code>attach</code> command in gdb to attach it to that
process.  One advantage of this method is that you have separate
<code>*R*</code> and <code>*gud-gdb*</code> windows.  Within the <code>*R*</code> window
you have all the <small>ESS</small> facilities, such as object-name
completion, that we know and love.

   <p>When using GUD mode for debugging from within Emacs, you may find it
most convenient to use the directory with your code in it as the current
working directory and then make a symbolic link from that directory to
the R binary.  That way <code>.gdbinit</code> can stay in the directory with
the code and be used to set up the environment and the search paths for
the source, e.g. as follows:

<pre class="example">     set env R_HOME /opt/R
     set env R_PAPERSIZE letter
     set env R_PRINTCMD lpr
     dir /opt/R/src/appl
     dir /opt/R/src/main
     dir /opt/R/src/nmath
     dir /opt/R/src/unix
     </pre>

<div class="node">
<p><hr>
Node:&nbsp;<a name="R%20Miscellanea">R Miscellanea</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#R%20Programming">R Programming</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20and%20Emacs">R and Emacs</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>
<br>
</div>

<h2 class="chapter">7 R Miscellanea</h2>

<ul class="menu">
<li><a accesskey="1" href="#Why%20does%20R%20run%20out%20of%20memory%3f">Why does R run out of memory?</a>: 
<li><a accesskey="2" href="#Why%20does%20sourcing%20a%20correct%20file%20fail%3f">Why does sourcing a correct file fail?</a>: 
<li><a accesskey="3" href="#How%20can%20I%20set%20components%20of%20a%20list%20to%20NULL%3f">How can I set components of a list to NULL?</a>: 
<li><a accesskey="4" href="#How%20can%20I%20save%20my%20workspace%3f">How can I save my workspace?</a>: 
<li><a accesskey="5" href="#How%20can%20I%20clean%20up%20my%20workspace%3f">How can I clean up my workspace?</a>: 
<li><a accesskey="6" href="#How%20can%20I%20get%20eval()%20and%20D()%20to%20work%3f">How can I get eval() and D() to work?</a>: 
<li><a accesskey="7" href="#Why%20do%20my%20matrices%20lose%20dimensions%3f">Why do my matrices lose dimensions?</a>: 
<li><a accesskey="8" href="#How%20does%20autoloading%20work%3f">How does autoloading work?</a>: 
<li><a accesskey="9" href="#How%20should%20I%20set%20options%3f">How should I set options?</a>: 
<li><a href="#How%20do%20file%20names%20work%20in%20Windows%3f">How do file names work in Windows?</a>: 
<li><a href="#Why%20does%20plotting%20give%20a%20color%20allocation%20error%3f">Why does plotting give a color allocation error?</a>: 
<li><a href="#How%20do%20I%20convert%20factors%20to%20numeric%3f">How do I convert factors to numeric?</a>: 
<li><a href="#Are%20Trellis%20displays%20implemented%20in%20R%3f">Are Trellis displays implemented in R?</a>: 
<li><a href="#What%20are%20the%20enclosing%20and%20parent%20environments%3f">What are the enclosing and parent environments?</a>: 
<li><a href="#How%20can%20I%20substitute%20into%20a%20plot%20label%3f">How can I substitute into a plot label?</a>: 
<li><a href="#What%20are%20valid%20names%3f">What are valid names?</a>: 
<li><a href="#Are%20GAMs%20implemented%20in%20R%3f">Are GAMs implemented in R?</a>: 
<li><a href="#Why%20is%20the%20output%20not%20printed%20when%20I%20source()%20a%20file%3f">Why is the output not printed when I source() a file?</a>: 
<li><a href="#Why%20does%20outer()%20behave%20strangely%20with%20my%20function%3f">Why does outer() behave strangely with my function?</a>: 
<li><a href="#Why%20does%20the%20output%20from%20anova()%20depend%20on%20the%20order%20of%20factors%20in%20the%20model%3f">Why does the output from anova() depend on the order of factors in the model?</a>: 
<li><a href="#How%20do%20I%20produce%20PNG%20graphics%20in%20batch%20mode%3f">How do I produce PNG graphics in batch mode?</a>: 
<li><a href="#How%20can%20I%20get%20command%20line%20editing%20to%20work%3f">How can I get command line editing to work?</a>: 
<li><a href="#How%20can%20I%20turn%20a%20string%20into%20a%20variable%3f">How can I turn a string into a variable?</a>: 
<li><a href="#Why%20do%20lattice%2ftrellis%20graphics%20not%20work%3f">Why do lattice/trellis graphics not work?</a>: 
<li><a href="#How%20can%20I%20sort%20the%20rows%20of%20a%20data%20frame%3f">How can I sort the rows of a data frame?</a>: 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Why%20does%20R%20run%20out%20of%20memory%3f">Why does R run out of memory?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Why%20does%20sourcing%20a%20correct%20file%20fail%3f">Why does sourcing a correct file fail?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20Miscellanea">R Miscellanea</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.1 Why does R run out of memory?</h3>

<p>Versions of R prior to 1.2.0 used a <em>static</em> memory model.  At
startup, R asked the operating system to reserve a fixed amount of
memory for it.  The size of this chunk could not be changed
subsequently.  Hence, it could happen that not enough memory was
allocated, e.g., when trying to read large data sets into R.  In such
cases, it was necessary to restart R with more memory available, as
controlled by the command line options <code>--nsize</code> and
<code>--vsize</code>.

   <p>R version 1.2.0 introduces a new "generational" garbage collector,
which will increase the memory available to R as needed.  Hence, user
intervention is no longer necessary for ensuring that enough memory is
available.

   <p>The new garbage collector does not move objects in memory, meaning that
it is possible for the free memory to become fragmented so that large
objects cannot be allocated even when there is apparently enough memory
for them.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Why%20does%20sourcing%20a%20correct%20file%20fail%3f">Why does sourcing a correct file fail?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20set%20components%20of%20a%20list%20to%20NULL%3f">How can I set components of a list to NULL?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Why%20does%20R%20run%20out%20of%20memory%3f">Why does R run out of memory?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.2 Why does sourcing a correct file fail?</h3>

<p>Versions of R prior to 1.2.1 may have had problems parsing files not
ending in a newline.  Earlier R versions had a similar problem when
reading in data files.  This should no longer happen.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20set%20components%20of%20a%20list%20to%20NULL%3f">How can I set components of a list to NULL?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20save%20my%20workspace%3f">How can I save my workspace?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Why%20does%20sourcing%20a%20correct%20file%20fail%3f">Why does sourcing a correct file fail?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.3 How can I set components of a list to NULL?</h3>

<p>You can use

<pre class="example">     x[i] &lt;- list(NULL)
     </pre>

<p>to set component <code>i</code> of the list <code>x</code> to <code>NULL</code>, similarly
for named components.  Do not set <code>x[i]</code> or <code>x[[i]]</code> to
<code>NULL</code>, because this will remove the corresponding component from
the list.

   <p>For dropping the row names of a matrix <code>x</code>, it may be easier to use
<code>rownames(x) &lt;- NULL</code>, similarly for column names.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20save%20my%20workspace%3f">How can I save my workspace?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20clean%20up%20my%20workspace%3f">How can I clean up my workspace?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20I%20set%20components%20of%20a%20list%20to%20NULL%3f">How can I set components of a list to NULL?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.4 How can I save my workspace?</h3>

<p><code>save.image()</code> saves the objects in the user's <code>.GlobalEnv</code> to
the file <code>.RData</code> in the R startup directory.  (This is also what
happens after <kbd>q("yes")</kbd>.)  Using <code>save.image(</code><var>file</var><code>)</code> one
can save the image under a different name.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20clean%20up%20my%20workspace%3f">How can I clean up my workspace?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20get%20eval()%20and%20D()%20to%20work%3f">How can I get eval() and D() to work?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20I%20save%20my%20workspace%3f">How can I save my workspace?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.5 How can I clean up my workspace?</h3>

<p>To remove all objects in the currently active environment (typically
<code>.GlobalEnv</code>), you can do

<pre class="example">     rm(list = ls(all = TRUE))
     </pre>

<p>(Without <code>all = TRUE</code>, only the objects with names not starting
with a <code>.</code> are removed.)

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20get%20eval()%20and%20D()%20to%20work%3f">How can I get eval() and D() to work?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Why%20do%20my%20matrices%20lose%20dimensions%3f">Why do my matrices lose dimensions?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20I%20clean%20up%20my%20workspace%3f">How can I clean up my workspace?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.6 How can I get eval() and D() to work?</h3>

<p>Strange things will happen if you use <code>eval(print(x), envir = e)</code>
or <code>D(x^2, "x")</code>.  The first one will either tell you that
"<code>x</code>" is not found, or print the value of the wrong <code>x</code>. 
The other one will likely return zero if <code>x</code> exists, and an error
otherwise.

   <p>This is because in both cases, the first argument is evaluated in the
calling environment first.  The result (which should be an object of
mode <code>"expression"</code> or <code>"call"</code>) is then evaluated or
differentiated.  What you (most likely) really want is obtained by
"quoting" the first argument upon surrounding it with
<code>expression()</code>.  For example,

<pre class="example">     R&gt; D(expression(x^2), "x")
     2 * x
     </pre>

   <p>Although this behavior may initially seem to be rather strange, is
perfectly logical.  The "intuitive" behavior could easily be
implemented, but problems would arise whenever the expression is
contained in a variable, passed as a parameter, or is the result of a
function call.  Consider for instance the semantics in cases like

<pre class="example">     D2 &lt;- function(e, n) D(D(e, n), n)
     </pre>

<p>or

<pre class="example">     g &lt;- function(y) eval(substitute(y), sys.frame(sys.parent(n = 2)))
     g(a * b)
     </pre>

   <p>See the help page for <code>deriv()</code> for more examples.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Why%20do%20my%20matrices%20lose%20dimensions%3f">Why do my matrices lose dimensions?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20does%20autoloading%20work%3f">How does autoloading work?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20I%20get%20eval()%20and%20D()%20to%20work%3f">How can I get eval() and D() to work?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.7 Why do my matrices lose dimensions?</h3>

<p>When a matrix with a single row or column is created by a subscripting
operation, e.g., <code>row &lt;- mat[2, ]</code>, it is by default turned into a
vector.  In a similar way if an array with dimension, say, 2&nbsp;x&nbsp;3&nbsp;x&nbsp;1&nbsp;x&nbsp;4 is created by subscripting it will be coerced into a 2&nbsp;x&nbsp;3&nbsp;x&nbsp;4
array, losing the unnecessary dimension.  After much discussion this has
been determined to be a <em>feature</em>.

   <p>To prevent this happening, add the option <code>drop = FALSE</code> to the
subscripting.  For example,

<pre class="example">     rowmatrix &lt;- mat[2, , drop = FALSE]  # creates a row matrix
     colmatrix &lt;- mat[, 2, drop = FALSE]  # creates a column matrix
     a &lt;- b[1, 1, 1, drop = FALSE]        # creates a 1 x 1 x 1 array
     </pre>

   <p>The <code>drop = FALSE</code> option should be used defensively when
programming.  For example, the statement

<pre class="example">     somerows &lt;- mat[index, ]
     </pre>

<p>will return a vector rather than a matrix if <code>index</code> happens to
have length 1, causing errors later in the code.  It should probably be
rewritten as

<pre class="example">     somerows &lt;- mat[index, , drop = FALSE]
     </pre>

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20does%20autoloading%20work%3f">How does autoloading work?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20should%20I%20set%20options%3f">How should I set options?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Why%20do%20my%20matrices%20lose%20dimensions%3f">Why do my matrices lose dimensions?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.8 How does autoloading work?</h3>

<p>R has a special environment called <code>.AutoloadEnv</code>.  Using
<kbd>autoload(</kbd><var>name</var><kbd>, </kbd><var>pkg</var><kbd>)</kbd>, where <var>name</var> and
<var>pkg</var> are strings giving the names of an object and the package
containing it, stores some information in this environment.  When R
tries to evaluate <var>name</var>, it loads the corresponding package
<var>pkg</var> and reevaluates <var>name</var> in the new package's
environment.

   <p>Using this mechanism makes R behave as if the package was loaded, but
does not occupy memory (yet).

   <p>See the help page for <code>autoload()</code> for a very nice example.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20should%20I%20set%20options%3f">How should I set options?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20do%20file%20names%20work%20in%20Windows%3f">How do file names work in Windows?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20does%20autoloading%20work%3f">How does autoloading work?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.9 How should I set options?</h3>

<p>The function <code>options()</code> allows setting and examining a variety of
global "options" which affect the way in which R computes and displays
its results.  The variable <code>.Options</code> holds the current values of
these options, but should never directly be assigned to unless you want
to drive yourself crazy--simply pretend that it is a "read-only"
variable.

   <p>For example, given

<pre class="example">     test1 &lt;- function(x = pi, dig = 3) {
       oo &lt;- options(digits = dig); on.exit(options(oo));
       cat(.Options$digits, x, "\n")
     }
     test2 &lt;- function(x = pi, dig = 3) {
       .Options$digits &lt;- dig
       cat(.Options$digits, x, "\n")
     }
     </pre>

<p>we obtain:

<pre class="example">     R&gt; test1()
     3 3.14
     R&gt; test2()
     3 3.141593
     </pre>

   <p>What is really used is the <em>global</em> value of <code>.Options</code>, and
using <kbd>options(OPT = VAL)</kbd> correctly updates it.  Local copies of
<code>.Options</code>, either in <code>.GlobalEnv</code> or in a function
environment (frame), are just silently disregarded.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20do%20file%20names%20work%20in%20Windows%3f">How do file names work in Windows?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Why%20does%20plotting%20give%20a%20color%20allocation%20error%3f">Why does plotting give a color allocation error?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20should%20I%20set%20options%3f">How should I set options?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.10 How do file names work in Windows?</h3>

<p>As R uses C-style string handling, <code>\</code> is treated as an escape
character, so that for example one can enter a newline as <code>\n</code>. 
When you really need a <code>\</code>, you have to escape it with another
<code>\</code>.

   <p>Thus, in filenames use something like <code>"c:\\data\\money.dat"</code>.  You
can also replace <code>\</code> by <code>/</code> (<code>"c:/data/money.dat"</code>).

<div class="node">
<p><hr>
Node:&nbsp;<a name="Why%20does%20plotting%20give%20a%20color%20allocation%20error%3f">Why does plotting give a color allocation error?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20do%20I%20convert%20factors%20to%20numeric%3f">How do I convert factors to numeric?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20do%20file%20names%20work%20in%20Windows%3f">How do file names work in Windows?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.11 Why does plotting give a color allocation error?</h3>

<p>Sometimes plotting, e.g., when running <code>demo("image")</code>, results in
"Error: color allocation error".  This is an X problem, and only
indirectly related to R.  It occurs when applications started prior to R
have used all the available colors.  (How many colors are available
depends on the X configuration; sometimes only 256 colors can be used.)

   <p>One application which is notorious for "eating" colors is Netscape. 
If the problem occurs when Netscape is running, try (re)starting it with
either the <code>-no-install</code> (to use the default colormap) or the
<code>-install</code> (to install a private colormap) option.

   <p>You could also set the <code>colortype</code> of <code>X11()</code> to
<code>"pseudo.cube"</code> rather than the default <code>"pseudo"</code>.  See the
help page for <code>X11()</code> for more information.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20do%20I%20convert%20factors%20to%20numeric%3f">How do I convert factors to numeric?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Are%20Trellis%20displays%20implemented%20in%20R%3f">Are Trellis displays implemented in R?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Why%20does%20plotting%20give%20a%20color%20allocation%20error%3f">Why does plotting give a color allocation error?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.12 How do I convert factors to numeric?</h3>

<p>It may happen that when reading numeric data into R (usually, when
reading in a file), they come in as factors.  If <code>f</code> is such a
factor object, you can use

<pre class="example">     as.numeric(as.character(f))
     </pre>

<p>to get the numbers back.  More efficient, but harder to remember, is

<pre class="example">     as.numeric(levels(f))[as.integer(f)]
     </pre>

   <p>In any case, do not call <code>as.numeric()</code> or their likes directly for
the task at hand (as <code>as.numeric()</code> or <code>unclass()</code> give the
internal codes).

<div class="node">
<p><hr>
Node:&nbsp;<a name="Are%20Trellis%20displays%20implemented%20in%20R%3f">Are Trellis displays implemented in R?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#What%20are%20the%20enclosing%20and%20parent%20environments%3f">What are the enclosing and parent environments?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20do%20I%20convert%20factors%20to%20numeric%3f">How do I convert factors to numeric?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.13 Are Trellis displays implemented in R?</h3>

<p>The recommended package <strong>lattice</strong> (which is based on another
recommended package, <strong>grid</strong>) provides graphical functionality
that is compatible with most Trellis commands.

   <p>You could also look at <code>coplot()</code> and <code>dotchart()</code> which might
do at least some of what you want.  Note also that the R version of
<code>pairs()</code> is fairly general and provides most of the functionality
of <code>splom()</code>, and that R's default plot method has an argument
<code>asp</code> allowing to specify (and fix against device resizing) the
aspect ratio of the plot.

   <p>(Because the word "Trellis" has been claimed as a trademark we do not
use it in R.  The name "lattice" has been chosen for the R
equivalent.)

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20are%20the%20enclosing%20and%20parent%20environments%3f">What are the enclosing and parent environments?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20substitute%20into%20a%20plot%20label%3f">How can I substitute into a plot label?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Are%20Trellis%20displays%20implemented%20in%20R%3f">Are Trellis displays implemented in R?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.14 What are the enclosing and parent environments?</h3>

<p>Inside a function you may want to access variables in two additional
environments: the one that the function was defined in ("enclosing"),
and the one it was invoked in ("parent").

   <p>If you create a function at the command line or load it in a package its
enclosing environment is the global workspace.  If you define a function
<code>f()</code> inside another function <code>g()</code> its enclosing environment
is the environment inside <code>g()</code>.  The enclosing environment for a
function is fixed when the function is created.  You can find out the
enclosing environment for a function <code>f()</code> using
<code>environment(f)</code>.

   <p>The "parent" environment, on the other hand, is defined when you
invoke a function.  If you invoke <code>lm()</code> at the command line its
parent environment is the global workspace, if you invoke it inside a
function <code>f()</code> then its parent environment is the environment
inside <code>f()</code>.  You can find out the parent environment for an
invocation of a function by using <code>parent.frame()</code> or
<code>sys.frame(sys.parent())</code>.

   <p>So for most user-visible functions the enclosing environment will be the
global workspace, since that is where most functions are defined.  The
parent environment will be wherever the function happens to be called
from.  If a function <code>f()</code> is defined inside another function
<code>g()</code> it will probably be used inside <code>g()</code> as well, so its
parent environment and enclosing environment will probably be the same.

   <p>Parent environments are important because things like model formulas
need to be evaluated in the environment the function was called from,
since that's where all the variables will be available.  This relies on
the parent environment being potentially different with each invocation.

   <p>Enclosing environments are important because a function can use
variables in the enclosing environment to share information with other
functions or with other invocations of itself (see the section on
lexical scoping).  This relies on the enclosing environment being the
same each time the function is invoked.

   <p>Scoping <em>is</em> hard.  Looking at examples helps.  It is particularly
instructive to look at examples that work differently in R and S and try
to see why they differ.  One way to describe the scoping differences
between R and S is to say that in S the enclosing environment is
<em>always</em> the global workspace, but in R the enclosing environment
is wherever the function was created.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20substitute%20into%20a%20plot%20label%3f">How can I substitute into a plot label?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#What%20are%20valid%20names%3f">What are valid names?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20are%20the%20enclosing%20and%20parent%20environments%3f">What are the enclosing and parent environments?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.15 How can I substitute into a plot label?</h3>

<p>Often, it is desired to use the value of an R object in a plot label,
e.g., a title.  This is easily accomplished using <code>paste()</code> if the
label is a simple character string, but not always obvious in case the
label is an expression (for refined mathematical annotation).  In such a
case, either use <code>parse()</code> on your pasted character string or use
<code>substitute()</code> on an expression.  For example, if <code>ahat</code> is an
estimator of your parameter a of interest, use

<pre class="example">     title(substitute(hat(a) == ahat, list(ahat = ahat)))
     </pre>

<p>(note that it is <code>==</code> and not <code>=</code>).  There are more worked
examples in the mailing list achives.

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20are%20valid%20names%3f">What are valid names?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Are%20GAMs%20implemented%20in%20R%3f">Are GAMs implemented in R?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20I%20substitute%20into%20a%20plot%20label%3f">How can I substitute into a plot label?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.16 What are valid names?</h3>

<p>When creating data frames using <code>data.frame()</code> or
<code>read.table()</code>, R by default ensures that the variable names are
syntactically valid.  (The argument <code>check.names</code> to these
functions controls whether variable names are checked and adjusted by
<code>make.names()</code> if needed.)

   <p>To understand what names are "valid", one needs to take into account
that the term "name" is used in several different (but related) ways
in the language:

     <ol type=1 start=1>
<li>A <em>syntactic name</em> is a string the parser interprets as this type
of expression.  It consists of letters, numbers, and the dot character
and starts with a letter or the dot.

     <li>An <em>object name</em> is a string associated with an object that is
assigned in an expression either by having the object name on the left
of an assignment operation or as an argument to the <code>assign()</code>
function.  It is usually a syntactic name as well, but can be any
non-empty string if it is quoted (and it is always quoted in the call to
<code>assign()</code>).

     <li>An <em>argument name</em> is what appears to the left of the equals sign
when supplying an argument in a function call (for example,
<code>f(trim=.5)</code>).  Argument names are also usually syntactic names,
but again can be anything if they are quoted.

     <li>An <em>element name</em> is a string that identifies a piece of an object
(a component of a list, for example.)  When it is used on the right of
the <code>$</code> operator, it must be a syntactic name, or quoted. 
Otherwise, element names can be any strings.  (When an object is used as
a database, as in a call to <code>eval()</code> or <code>attach()</code>, the
element names become object names.)

     <li>Finally, a <em>file name</em> is a string identifying a file in the
operating system for reading, writing, etc.  It really has nothing much
to do with names in the language, but it is traditional to call these
strings file "names".
        </ol>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Are%20GAMs%20implemented%20in%20R%3f">Are GAMs implemented in R?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Why%20is%20the%20output%20not%20printed%20when%20I%20source()%20a%20file%3f">Why is the output not printed when I source() a file?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20are%20valid%20names%3f">What are valid names?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.17 Are GAMs implemented in R?</h3>

<p>There is a <code>gam()</code> function for Generalized Additive Models in
package <strong>mgcv</strong>, but it is not an exact clone of what is described
in the White Book (no <code>lo()</code> for example).  Package <strong>gss</strong>
can fit spline-based GAMs too.  And if you can accept regression splines
you can use <code>glm()</code>.  For gaussian GAMs you can use <code>bruto()</code>
from package <strong>mda</strong>.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Why%20is%20the%20output%20not%20printed%20when%20I%20source()%20a%20file%3f">Why is the output not printed when I source() a file?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Why%20does%20outer()%20behave%20strangely%20with%20my%20function%3f">Why does outer() behave strangely with my function?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Are%20GAMs%20implemented%20in%20R%3f">Are GAMs implemented in R?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.18 Why is the output not printed when I source() a file?</h3>

<p>Most R commands do not generate any output. The command

<pre class="example">     1+1
     </pre>

<p>computes the value 2 and returns it; the command

<pre class="example">     summary(glm(y~x+z, family=binomial))
     </pre>

<p>fits a logistic regression model, computes some summary information and
returns an object of class <code>"summary.glm"</code> (see <a href="#How%20should%20I%20write%20summary%20methods%3f">How should I write summary methods?</a>).

   <p>If you type <code>1+1</code> or <code>summary(glm(y~x+z, family=binomial))</code> at
the command line the returned value is automatically printed (unless it
is <code>invisible()</code>), but in other circumstances, such as in a
<code>source()</code>d file or inside a function it isn't printed unless you
specifically print it.

   <p>To print the value use

<pre class="example">     print(1+1)
     </pre>

<p>or

<pre class="example">     print(summary(glm(y~x+z, family=binomial)))
     </pre>

<p>instead, or use <code>source(</code><var>file</var><code>, echo=TRUE)</code>.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Why%20does%20outer()%20behave%20strangely%20with%20my%20function%3f">Why does outer() behave strangely with my function?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Why%20does%20the%20output%20from%20anova()%20depend%20on%20the%20order%20of%20factors%20in%20the%20model%3f">Why does the output from anova() depend on the order of factors in the model?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Why%20is%20the%20output%20not%20printed%20when%20I%20source()%20a%20file%3f">Why is the output not printed when I source() a file?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.19 Why does outer() behave strangely with my function?</h3>

<p>As the help for <code>outer()</code> indicates, it does not work on arbitrary
functions the way the <code>apply()</code> family does.  It requires functions
that are vectorized to work elementwise on arrays.  As you can see by
looking at the code, <code>outer(x, y, FUN)</code> creates two large vectors
containing every possible combination of elements of <code>x</code> and
<code>y</code> and then passes this to <code>FUN</code> all at once.  Your function
probably cannot handle two large vectors as parameters.

   <p>If you have a function that cannot handle two vectors but can handle two
scalars, then you can still use <code>outer()</code> but you will need to wrap
your function up first, to simulate vectorized behavior.  Suppose your
function is

<pre class="example">     foo &lt;- function(x, y, happy) {
       stopifnot(length(x) == 1, length(y) == 1) # scalars only!
       (x + y) * happy
     }
     </pre>

<p>If you define the general function

<pre class="example">     wrapper &lt;- function(x, y, my.fun, ...) {
       sapply(seq(along = x), FUN = function(i) my.fun(x[i], y[i], ...))
     }
     </pre>

<p>then you can use <code>outer()</code> by writing, e.g.,

<pre class="example">     outer(1:4, 1:2, FUN = wrapper, my.fun = foo, happy = 10)
     </pre>

<div class="node">
<p><hr>
Node:&nbsp;<a name="Why%20does%20the%20output%20from%20anova()%20depend%20on%20the%20order%20of%20factors%20in%20the%20model%3f">Why does the output from anova() depend on the order of factors in the model?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20do%20I%20produce%20PNG%20graphics%20in%20batch%20mode%3f">How do I produce PNG graphics in batch mode?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Why%20does%20outer()%20behave%20strangely%20with%20my%20function%3f">Why does outer() behave strangely with my function?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.20 Why does the output from anova() depend on the order of factors in the model?</h3>

<p>In a model such as <code>~A+B+A:B</code>, R will report the difference in sums
of squares between the models <code>~1</code>, <code>~A</code>, <code>~A+B</code> and
<code>~A+B+A:B</code>.  If the model were <code>~B+A+A:B</code>, R would report
differences between <code>~1</code>, <code>~B</code>, <code>~A+B</code>, and
<code>~A+B+A:B</code> . In the first case the sum of squares for <code>A</code> is
comparing <code>~1</code> and <code>~A</code>, in the second case it is comparing
<code>~B</code> and <code>~B+A</code>.  In a non-orthogonal design (i.e., most
unbalanced designs) these comparisons are (conceptually and numerically)
different.

   <p>Some packages report instead the sums of squares based on comparing the
full model to the models with each factor removed one at a time (the
famous `Type III sums of squares' from SAS, for example).  These do not
depend on the order of factors in the model.  The question of which set
of sums of squares is the Right Thing provokes low-level holy wars on
R-help from time to time.

   <p>There is no need to be agitated about the particular sums of squares
that R reports.  You can compute your favorite sums of squares quite
easily.  Any two models can be compared with <code>anova(</code><var>model1</var><code>,
</code><var>model2</var><code>)</code>, and <code>drop1(</code><var>model1</var><code>)</code> will show the sums of
squares resulting from dropping single terms.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20do%20I%20produce%20PNG%20graphics%20in%20batch%20mode%3f">How do I produce PNG graphics in batch mode?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20get%20command%20line%20editing%20to%20work%3f">How can I get command line editing to work?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Why%20does%20the%20output%20from%20anova()%20depend%20on%20the%20order%20of%20factors%20in%20the%20model%3f">Why does the output from anova() depend on the order of factors in the model?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.21 How do I produce PNG graphics in batch mode?</h3>

<p>Under Unix, the <code>png()</code> device uses the X11 driver, which is a
problem in batch mode or for remote operation.  If you have Ghostscript
you can use <code>bitmap()</code>, which produces a PostScript file then
converts it to any bitmap format supported by ghostscript.  On some
installations this produces ugly output, on others it is perfectly
satisfactory.  In theory one could also use Xvfb, which provides an X
server with no display.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20get%20command%20line%20editing%20to%20work%3f">How can I get command line editing to work?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20turn%20a%20string%20into%20a%20variable%3f">How can I turn a string into a variable?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20do%20I%20produce%20PNG%20graphics%20in%20batch%20mode%3f">How do I produce PNG graphics in batch mode?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.22 How can I get command line editing to work?</h3>

<p>The Unix command-line interface to R can only provide the inbuilt
command line editor which allows recall, editing and re-submission of
prior commands provided that the <small>GNU</small> readline library is
available at the time R is configured for compilation.  Note that the
`development' version of readline including the appropriate headers is
needed: users of Linux binary distributions will need to install
packages such as <code>libreadline-dev</code> (Debian) or
<code>readline-devel</code> (Red Hat).

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20turn%20a%20string%20into%20a%20variable%3f">How can I turn a string into a variable?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Why%20do%20lattice%2ftrellis%20graphics%20not%20work%3f">Why do lattice/trellis graphics not work?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20I%20get%20command%20line%20editing%20to%20work%3f">How can I get command line editing to work?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.23 How can I turn a string into a variable?</h3>

<p>If you have

<pre class="example">     varname &lt;- c("a", "b", "d")
     </pre>

<p>you can do

<pre class="example">     get(varname[1]) + 2
     </pre>

<p>for

<pre class="example">     a + 2
     </pre>

<p>or

<pre class="example">     assign(varname[1], 2 + 2)
     </pre>

<p>for

<pre class="example">     a &lt;- 2 + 2
     </pre>

<p>or

<pre class="example">     eval(substitute(lm(y ~ x + variable),
                     list(variable = as.name(varname[1]))
     </pre>

<p>for

<pre class="example">     lm(y ~ x + a)
     </pre>

   <p>At least in the first two cases it is often easier to just use a list,
and then you can easily index it by name

<pre class="example">     vars &lt;- list(a = 1:10, b = rnorm(100), d = LETTERS)
     vars[["a"]]
     </pre>

<p>without any of this messing about.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Why%20do%20lattice%2ftrellis%20graphics%20not%20work%3f">Why do lattice/trellis graphics not work?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20sort%20the%20rows%20of%20a%20data%20frame%3f">How can I sort the rows of a data frame?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20I%20turn%20a%20string%20into%20a%20variable%3f">How can I turn a string into a variable?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.24 Why do lattice/trellis graphics not work?</h3>

<p>The most likely reason is that you forgot to tell R to display the
graph.  Lattice functions such as <code>xyplot()</code> create a graph object,
but do not display it (the same is true of Trellis graphics in
<small>S-PLUS</small>).  The <code>print()</code> method for the graph object produces the
actual display.  When you use these functions interactively at the
command line, the result is automatically printed, but in
<code>source()</code> or inside your own functions you will need an explicit
<code>print()</code> statement.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20sort%20the%20rows%20of%20a%20data%20frame%3f">How can I sort the rows of a data frame?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#Why%20do%20lattice%2ftrellis%20graphics%20not%20work%3f">Why do lattice/trellis graphics not work?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Miscellanea">R Miscellanea</a>
<br>
</div>

<h3 class="section">7.25 How can I sort the rows of a data frame?</h3>

<p>To sort the rows within a data frame, with respect to the values in one
or more of the columns, simply use <code>order()</code>.

<div class="node">
<p><hr>
Node:&nbsp;<a name="R%20Programming">R Programming</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#R%20Bugs">R Bugs</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20Miscellanea">R Miscellanea</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>
<br>
</div>

<h2 class="chapter">8 R Programming</h2>

<ul class="menu">
<li><a accesskey="1" href="#How%20should%20I%20write%20summary%20methods%3f">How should I write summary methods?</a>: 
<li><a accesskey="2" href="#How%20can%20I%20debug%20dynamically%20loaded%20code%3f">How can I debug dynamically loaded code?</a>: 
<li><a accesskey="3" href="#How%20can%20I%20inspect%20R%20objects%20when%20debugging%3f">How can I inspect R objects when debugging?</a>: 
<li><a accesskey="4" href="#How%20can%20I%20change%20compilation%20flags%3f">How can I change compilation flags?</a>: 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20should%20I%20write%20summary%20methods%3f">How should I write summary methods?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20debug%20dynamically%20loaded%20code%3f">How can I debug dynamically loaded code?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20Programming">R Programming</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Programming">R Programming</a>
<br>
</div>

<h3 class="section">8.1 How should I write summary methods?</h3>

<p>Suppose you want to provide a summary method for class <code>"foo"</code>. 
Then <code>summary.foo()</code> should not print anything, but return an
object of class <code>"summary.foo"</code>, <em>and</em> you should write a
method <code>print.summary.foo()</code> which nicely prints the summary
information and invisibly returns its object.  This approach is
preferred over having <code>summary.foo()</code> print summary information and
return something useful, as sometimes you need to grab something
computed by <code>summary()</code> inside a function or similar.  In such
cases you don't want anything printed.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20debug%20dynamically%20loaded%20code%3f">How can I debug dynamically loaded code?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20inspect%20R%20objects%20when%20debugging%3f">How can I inspect R objects when debugging?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20should%20I%20write%20summary%20methods%3f">How should I write summary methods?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Programming">R Programming</a>
<br>
</div>

<h3 class="section">8.2 How can I debug dynamically loaded code?</h3>

<p>Roughly speaking, you need to start R inside the debugger, load the
code, send an interrupt, and then set the required breakpoints.

   <p>See section "Finding entry points in dynamically loaded code" in
<cite>Writing R Extensions</cite>. 
This manual is included in the R distribution, see <a href="#What%20documentation%20exists%20for%20R%3f">What documentation exists for R?</a>.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20inspect%20R%20objects%20when%20debugging%3f">How can I inspect R objects when debugging?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20can%20I%20change%20compilation%20flags%3f">How can I change compilation flags?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20I%20debug%20dynamically%20loaded%20code%3f">How can I debug dynamically loaded code?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Programming">R Programming</a>
<br>
</div>

<h3 class="section">8.3 How can I inspect R objects when debugging?</h3>

<p>The most convenient way is to call <code>R_PV</code> from the symbolic
debugger.

   <p>See section "Inspecting R objects when debugging" in <cite>Writing R
Extensions</cite>.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20can%20I%20change%20compilation%20flags%3f">How can I change compilation flags?</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#How%20can%20I%20inspect%20R%20objects%20when%20debugging%3f">How can I inspect R objects when debugging?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Programming">R Programming</a>
<br>
</div>

<h3 class="section">8.4 How can I change compilation flags?</h3>

<p>Suppose you have C code file for dynloading into R, but you want to use
<code>R CMD SHLIB</code> with compilation flags other than the default ones
(which were determined when R was built).  You could change the file
<code>R_HOME/etc/Makeconf</code> to reflect your preferences.  If you
are a Bourne shell user, you can also pass the desired flags to Make
(which is used for controlling compilation) via the Make variable
<code>MAKEFLAGS</code>, as in

<pre class="example">     MAKEFLAGS="CFLAGS=-O3" R CMD SHLIB *.c
     </pre>

<div class="node">
<p><hr>
Node:&nbsp;<a name="R%20Bugs">R Bugs</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#Acknowledgments">Acknowledgments</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20Programming">R Programming</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>
<br>
</div>

<h2 class="chapter">9 R Bugs</h2>

<ul class="menu">
<li><a accesskey="1" href="#What%20is%20a%20bug%3f">What is a bug?</a>: 
<li><a accesskey="2" href="#How%20to%20report%20a%20bug">How to report a bug</a>: 
</ul>

<div class="node">
<p><hr>
Node:&nbsp;<a name="What%20is%20a%20bug%3f">What is a bug?</a>,
Next:&nbsp;<a rel="next" accesskey="n" href="#How%20to%20report%20a%20bug">How to report a bug</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20Bugs">R Bugs</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Bugs">R Bugs</a>
<br>
</div>

<h3 class="section">9.1 What is a bug?</h3>

<p>If R executes an illegal instruction, or dies with an operating system
error message that indicates a problem in the program (as opposed to
something like "disk full"), then it is certainly a bug.  If you call
<code>.C()</code>, <code>.Fortran()</code>, <code>.External()</code> or <code>.Call()</code> (or
<code>.Internal()</code>) yourself (or in a function you wrote), you can
always crash R by using wrong argument types (modes).  This is not a
bug.

   <p>Taking forever to complete a command can be a bug, but you must make
certain that it was really R's fault.  Some commands simply take a long
time.  If the input was such that you <em>know</em> it should have been
processed quickly, report a bug.  If you don't know whether the command
should take a long time, find out by looking in the manual or by asking
for assistance.

   <p>If a command you are familiar with causes an R error message in a case
where its usual definition ought to be reasonable, it is probably a bug. 
If a command does the wrong thing, that is a bug.  But be sure you know
for certain what it ought to have done.  If you aren't familiar with the
command, or don't know for certain how the command is supposed to work,
then it might actually be working right.  Rather than jumping to
conclusions, show the problem to someone who knows for certain.

   <p>Finally, a command's intended definition may not be best for statistical
analysis.  This is a very important sort of problem, but it is also a
matter of judgment.  Also, it is easy to come to such a conclusion out
of ignorance of some of the existing features.  It is probably best not
to complain about such a problem until you have checked the
documentation in the usual ways, feel confident that you understand it,
and know for certain that what you want is not available.  If you are
not sure what the command is supposed to do after a careful reading of
the manual this indicates a bug in the manual.  The manual's job is to
make everything clear.  It is just as important to report documentation
bugs as program bugs.  However, we know that the introductory
documentation is seriously inadequate, so you don't need to report this.

   <p>If the online argument list of a function disagrees with the manual, one
of them must be wrong, so report the bug.

<div class="node">
<p><hr>
Node:&nbsp;<a name="How%20to%20report%20a%20bug">How to report a bug</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#What%20is%20a%20bug%3f">What is a bug?</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#R%20Bugs">R Bugs</a>
<br>
</div>

<h3 class="section">9.2 How to report a bug</h3>

<p>When you decide that there is a bug, it is important to report it and to
report it in a way which is useful.  What is most useful is an exact
description of what commands you type, starting with the shell command
to run R, until the problem happens.  Always include the version of R,
machine, and operating system that you are using; type <kbd>version</kbd> in
R to print this.

   <p>The most important principle in reporting a bug is to report
<em>facts</em>, not hypotheses or categorizations.  It is always easier to
report the facts, but people seem to prefer to strain to posit
explanations and report them instead.  If the explanations are based on
guesses about how R is implemented, they will be useless; others will
have to try to figure out what the facts must have been to lead to such
speculations.  Sometimes this is impossible.  But in any case, it is
unnecessary work for the ones trying to fix the problem.

   <p>For example, suppose that on a data set which you know to be quite large
the command

<pre class="example">     R&gt; data.frame(x, y, z, monday, tuesday)
     </pre>

<p>never returns.  Do not report that <code>data.frame()</code> fails for large
data sets.  Perhaps it fails when a variable name is a day of the week. 
If this is so then when others got your report they would try out the
<code>data.frame()</code> command on a large data set, probably with no day of
the week variable name, and not see any problem.  There is no way in the
world that others could guess that they should try a day of the week
variable name.

   <p>Or perhaps the command fails because the last command you used was a
method for <code>"["()</code> that had a bug causing R's internal data
structures to be corrupted and making the <code>data.frame()</code> command
fail from then on.  This is why others need to know what other commands
you have typed (or read from your startup file).

   <p>It is very useful to try and find simple examples that produce
apparently the same bug, and somewhat useful to find simple examples
that might be expected to produce the bug but actually do not.  If you
want to debug the problem and find exactly what caused it, that is
wonderful.  You should still report the facts as well as any
explanations or solutions.  Please include an example that reproduces
the problem, preferably the simplest one you have found.

   <p>Invoking R with the <code>--vanilla</code> option may help in isolating a
bug.  This ensures that the site profile and saved data files are not
read.

   <p>On Unix systems a bug report can be generated using the function
<code>bug.report()</code>.  This automatically includes the version
information and sends the bug to the correct address.  Alternatively the
bug report can be emailed to <a href="mailto:R-bugs@R-project.org">R-bugs@R-project.org</a> or submitted
to the Web page at <a href="http://bugs.R-project.org/">http://bugs.R-project.org/</a>.

   <p>Bug reports on contributed packages should perhaps be sent to the
package maintainer rather than to R-bugs.

<div class="node">
<p><hr>
Node:&nbsp;<a name="Acknowledgments">Acknowledgments</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#R%20Bugs">R Bugs</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#Top">Top</a>
<br>
</div>

<h2 class="chapter">10 Acknowledgments</h2>

<p>Of course, many many thanks to Robert and Ross for the R system, and to
the package writers and porters for adding to it.

   <p>Special thanks go to Doug Bates, Peter Dalgaard, Paul Gilbert, Stefano
Iacus, Fritz Leisch, Jim Lindsey, Thomas Lumley, Martin Maechler, Brian
D. Ripley, Anthony Rossini, and Andreas Weingessel for their comments
which helped me improve this <small>FAQ</small>.

   <p>More to some soon <small class="dots">...</small>

   </body></html>