R FAQ


Next: , Previous: (dir), Up: (dir)

R FAQ

Frequently Asked Questions on R

Version 2.7.2008-06-15

ISBN 3-900051-08-9

Kurt Hornik



Next: , Previous: Top, Up: Top

1 Introduction

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


Next: , Previous: Introduction, Up: Introduction

1.1 Legalese

This document is copyright © 1998–2008 by Kurt Hornik.

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

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 GNU General Public License for more details.

A copy of the GNU General Public License is available via WWW at

     http://www.gnu.org/copyleft/gpl.html.

You can also obtain it by writing to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, U.S.A.


Next: , Previous: Legalese, Up: Introduction

1.2 Obtaining this document

The latest version of this document is always available from

     http://CRAN.R-project.org/doc/FAQ/

From there, you can obtain versions converted to plain ASCII text, DVI, GNU info, HTML, PDF, PostScript as well as the Texinfo source used for creating all these formats using the GNU Texinfo system.

You can also obtain the R FAQ from the doc/FAQ subdirectory of a CRAN site (see What is CRAN?).


Next: , Previous: Obtaining this document, Up: Introduction

1.3 Citing this document

In publications, please refer to this FAQ as Hornik (2008), “The R FAQ”, and give the above, official URL and the ISBN 3-900051-08-9:

     @Misc{,
       author        = {Kurt Hornik},
       title         = {The {R} {FAQ}},
       year          = {2008},
       note          = {{ISBN} 3-900051-08-9},
       url           = {http://CRAN.R-project.org/doc/FAQ/R-FAQ.html}
     }


Next: , Previous: Citing this document, Up: Introduction

1.4 Notation

Everything should be pretty standard. ‘R>’ is used for the R prompt, and a ‘$’ for the shell prompt (where applicable).


Previous: Notation, Up: Introduction

1.5 Feedback

Feedback via email to Kurt.Hornik@R-project.org is of course most welcome.

In particular, note that I do not have access to Windows or Macintosh systems. Features specific to the Windows and Mac OS X ports of R are described in the “R for Windows FAQ and the “R for Mac OS X FAQ. If you have information on Macintosh or Windows systems that you think should be added to this document, please let me know.


Next: , Previous: Introduction, Up: Top

2 R Basics


Next: , Previous: R Basics, Up: R Basics

2.1 What is R?

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.

The design of R has been heavily influenced by two existing languages: Becker, Chambers & Wilks' S (see What is S?) and Sussman's Scheme. Whereas the resulting language is very similar in appearance to S, the underlying implementation and semantics are derived from Scheme. See What are the differences between R and S?, for further details.

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 R Add-On Packages).

R was initially written by Ross Ihaka and Robert Gentleman 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.

Since mid-1997 there has been a core group (the “R Core Team”) who can modify the R source code 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, Luke Tierney, and Simon Urbanek.

R has a home page at http://www.R-project.org/. It is free software distributed under a GNU-style copyleft, and an official part of the GNU project (“GNU S”).


Next: , Previous: What is R?, Up: R Basics

2.2 What machines does R run on?

R is being developed for the Unix, Windows and Mac families of operating systems. Support for Mac OS Classic ended with R 1.7.1.

The current version of R will configure and build under a number of common Unix platforms including cpu-linux-gnu for the i386, alpha, arm, hppa, ia64, m68k, mips/mipsel, powerpc, s390, sparc (e.g., http://buildd.debian.org/build.php?&pkg=r-base), and x86_64 CPUs, powerpc-apple-darwin, mips-sgi-irix, rs6000-ibm-aix, and sparc-sun-solaris.

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


Next: , Previous: What machines does R run on?, Up: R Basics

2.3 What is the current version of R?

The current released version is 2.7.0. Based on this `major.minor.patchlevel' numbering scheme, there are two development versions of R, a patched version of the current release (`r-patched') and one working towards the next 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.


Next: , Previous: What is the current version of R?, Up: R Basics

2.4 How can R be obtained?

Sources, binaries and documentation for R can be obtained via CRAN, the “Comprehensive R Archive Network” (see What is CRAN?).

Sources are also available via https://svn.R-project.org/R/, the R Subversion repository, but currently not via anonymous rsync (nor CVS).

Tarballs with daily snapshots of the r-devel and r-patched development versions of R can be found at ftp://ftp.stat.math.ethz.ch/Software/R.


Next: , Previous: How can R be obtained?, Up: R Basics

2.5 How can R be installed?


Next: , Previous: How can R be installed?, Up: How can R be installed?

2.5.1 How can R be installed (Unix)

If R is already installed, it can be started by typing R at the shell prompt (of course, provided that the executable is in your path).

If binaries are available for your platform (see Are there Unix binaries for R?), you can use these, following the instructions that come with them.

Otherwise, you can compile and install R yourself, which can be done very easily under a number of common Unix platforms (see What machines does R run on?). The file INSTALL that comes with the R distribution contains a brief introduction, and the “R Installation and Administration” guide (see What documentation exists for R?) has full details.

Note that you need a FORTRAN compiler or perhaps f2c 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 CRAN.)

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

     $ ./configure
     $ make

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

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

Finally, use make check to find out whether your R system works correctly.

You can also perform a “system-wide” installation using make install. By default, this will install to the following directories:

${prefix}/bin
the front-end shell script
${prefix}/man/man1
the man page
${prefix}/lib/R
all the rest (libraries, on-line help system, ...). This is the “R Home Directory” (R_HOME) of the installed system.

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

     $ ./configure --prefix=/where/you/want/R/to/go

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

To install DVI, info and PDF versions of the manuals, use make install-dvi, make install-info and make install-pdf, respectively.


Next: , Previous: How can R be installed (Unix), Up: How can R be installed?

2.5.2 How can R be installed (Windows)

The bin/windows directory of a CRAN site contains binaries for a base distribution and a large number of add-on packages from CRAN 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 Guido Masarotto, and is now being developed and maintained by Duncan Murdoch and Brian D. Ripley.

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

See the “R for Windows FAQ for more details.


Previous: How can R be installed (Windows), Up: How can R be installed?

2.5.3 How can R be installed (Macintosh)

The bin/macosx directory of a CRAN site contains a standard Apple installer package inside a disk image named R.dmg. Once downloaded and executed, the installer will install the current non-developer release of R. RAqua is a native Mac OS X Darwin version of R with a R.app Mac OS X GUI. Inside bin/macosx/powerpc/contrib/x.y there are prebuilt binary packages (for powerpc version of Mac OS X) to be used with RAqua corresponding to the “x.y” release of R. The installation of these packages is available through the “Package” menu of the R.app GUI. This port of R for Mac OS X is maintained by Stefano Iacus. The “R for Mac OS X FAQ has more details.

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


Next: , Previous: How can R be installed?, Up: R Basics

2.6 Are there Unix binaries for R?

The bin/linux directory of a CRAN site contains the following packages.

CPU Versions Provider
Debian i386/amd64 stable/oldstable Johannes Ranke
Red Hat i386/x86_64 fedora7/fedora8 Martyn Plummer
i386/x86_64 el4/el5 Bob Kinney
SuSE i586/x86_64 10.0/10.1/10.2/10.3 Detlef Steuer
Ubuntu i386 dapper/feisty/gutsy/hardy Vincent Goulet
amd64 dapper/feisty/gutsy/hardy Michael Rutter

Debian packages, maintained by Dirk Eddelbuettel and Doug Bates, have long been part of the Debian distribution, and can be accessed through APT, the Debian package maintenance tool. Use e.g. apt-get install r-base r-recommended to install the R environment and recommended packages. If you also want to build R packages from source, also run apt-get install r-base-dev to obtain the additional tools required for this. So-called “backports” of the current R packages for the stable distribution of Debian are provided by Johannes Ranke, and available from CRAN. Simply add the line

     deb http://CRAN.R-project.org/bin/linux/debian stable/

(feel free to use a CRAN mirror instead of the master) to the file /etc/apt/sources.list, and install as usual. More details on installing and administering R on Debian Linux can be found at http://CRAN.R-project.org/bin/linux/debian/README. These backports should also be suitable for other Debian derivatives. Native backports for Ubuntu are provided by Vincent Goulet and Michael Rutter.

On SUSE, you can set up an installation source for R within Yast by setting (e.g.)

     Protocol: HTTP
     Server name: software.openSUSE.org
     Directory: /download/home:/dsteuer/openSUSE_10.2/

With this setting, online updates will check for new versions of R.

No other binary distributions are currently publically available via CRAN.

A “live” Linux distribution with a particular focus on R is Quantian, which provides a directly bootable and self-configuring “Live DVD” containing numerous applications of interests to scientists and researchers, including several hundred CRAN and Bioconductor packages, the “ESS” extensions for Emacs, the “JGR” Java GUI for R, the Ggobi visualization tool as well as several other R interfaces. The Quantian website at http://dirk.eddelbuettel.com/quantian/ contains more details as well download information.


Next: , Previous: Are there Unix binaries for R?, Up: R Basics

2.7 What documentation exists for R?

Online documentation for most of the functions and variables in R exists, and can be printed on-screen by typing help(name) (or ?name) at the R prompt, where name 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.)

This documentation can also be made available as one reference manual for on-line reading in HTML and PDF formats, and as hardcopy via LaTeX, see How can R be installed?. An up-to-date HTML version is always available for web browsing at http://stat.ethz.ch/R-manual/.

Printed copies of the R reference manual for some version(s) are available from Network Theory Ltd, at http://www.network-theory.co.uk/R/base/. For each set of manuals sold, the publisher donates USD 10 to the R Foundation (see What is the R Foundation?).

The R distribution also comes with the following manuals.

Books on R include

P. Dalgaard (2002), “Introductory Statistics with R”, Springer: New York, ISBN 0-387-95475-9, http://www.biostat.ku.dk/~pd/ISwR.html.

J. Fox (2002), “An R and S-Plus Companion to Applied Regression”, Sage Publications, ISBN 0-761-92280-6 (softcover) or 0-761-92279-2 (hardcover), http://socserv.socsci.mcmaster.ca/jfox/Books/Companion/.

J. Maindonald and J. Braun (2003), “Data Analysis and Graphics Using R: An Example-Based Approach”, Cambridge University Press, ISBN 0-521-81336-0, http://wwwmaths.anu.edu.au/~johnm/.

S. M. Iacus and G. Masarotto (2002), “Laboratorio di statistica con R”, McGraw-Hill, ISBN 88-386-6084-0 (in Italian),
http://www.ateneonline.it/LibroAteneo.asp?item_id=1436.

P. Murrell (2005), “R Graphics”, Chapman & Hall/CRC, ISBN: 1-584-88486-X, http://www.stat.auckland.ac.nz/~paul/RGraphics/rgraphics.html.

The book

W. N. Venables and B. D. Ripley (2002), “Modern Applied Statistics with S. Fourth Edition”. Springer, ISBN 0-387-95457-0

has a home page at http://www.stats.ox.ac.uk/pub/MASS4/ providing additional material. Its companion is

W. N. Venables and B. D. Ripley (2000), “S Programming”. Springer, ISBN 0-387-98966-8

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

In addition to material written specifically or explicitly for R, documentation for S/S-Plus (see R and S) can be used in combination with this FAQ (see What are the differences between R and S?). Introductory books include

P. Spector (1994), “An introduction to S and S-Plus”, Duxbury Press.

A. Krause and M. Olsen (2005), “The Basics of S-Plus” (Fourth Edition). Springer, ISBN 0-387-26109-5.

The book

J. C. Pinheiro and D. M. Bates (2000), “Mixed-Effects Models in S and S-Plus”, Springer, ISBN 0-387-98957-0

provides a comprehensive guide to the use of the nlme package for linear and nonlinear mixed-effects models.

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

D. Nolan and T. Speed (2000), “Stat Labs: Mathematical Statistics Through Applications”, Springer Texts in Statistics, ISBN 0-387-98974-9

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 http://www.stat.Berkeley.EDU/users/statlabs/.

Last, but not least, Ross' and Robert's experience in designing and implementing R is described in Ihaka & Gentleman (1996), “R: A Language for Data Analysis and Graphics”, Journal of Computational and Graphical Statistics, 5, 299–314.

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

     http://www.R-project.org/doc/bib/R.bib


Next: , Previous: What documentation exists for R?, Up: R Basics

2.8 Citing R

To cite R in publications, use

     @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         = 2008,
       note         = {{ISBN} 3-900051-07-0},
       url          = {http://www.R-project.org}
     }

Citation strings (or BibTeX entries) for R and R packages can also be obtained by citation().


Next: , Previous: Citing R, Up: R Basics

2.9 What mailing lists exist for R?

Thanks to Martin Maechler, there are four mailing lists devoted to R.

R-announce
A moderated list for major announcements about the development of R and the availability of new code.
R-packages
A moderated list for announcements on the availability of new or enhanced contributed packages.
R-help
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.
R-devel
This list is for questions and discussion about code development in R.

Please read the posting guide before sending anything to any mailing list.

Note in particular that R-help is intended to be comprehensible to people who want to use R to solve problems but who are not necessarily interested in or knowledgeable about programming. Questions likely to prompt discussion unintelligible to non-programmers (e.g., questions involving C or C++) should go to R-devel.

Convenient access to information on these lists, subscription, and archives is provided by the web interface at http://stat.ethz.ch/mailman/listinfo/. One can also subscribe (or unsubscribe) via email, e.g. to R-help by sending ‘subscribe’ (or ‘unsubscribe’) in the body of the message (not in the subject!) to R-help-request@lists.R-project.org.

Send email to R-help@lists.R-project.org to send a message to everyone on the R-help mailing list. Subscription and posting to the other lists is done analogously, with ‘R-help’ replaced by ‘R-announce’, ‘R-packages’, and ‘R-devel’, respectively. 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.

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.

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 R Bugs for more details.

See http://www.R-project.org/mail.html for more information on the R mailing lists.

The R Core Team can be reached at R-core@lists.R-project.org for comments and reports.

Many of the R project's mailing lists are also available via Gmane, from which they can be read with a web browser, using an NNTP news reader, or via RSS feeds. See http://dir.gmane.org/index.php?prefix=gmane.comp.lang.r. for the available mailing lists, and http://www.gmane.org/rss.php for details on RSS feeds.


Next: , Previous: What mailing lists exist for R?, Up: R Basics

2.10 What is CRAN?

The “Comprehensive R Archive Network” (CRAN) is a collection of sites which carry identical material, consisting of the R distribution(s), the contributed extensions, documentation for R, and binaries.

The CRAN master site at Wirtschaftsuniversität Wien, Austria, can be found at the URL

http://CRAN.R-project.org/

Daily mirrors are available at URLs including

http://cran.at.R-project.org/ (WU Wien, Austria)
http://cran.au.R-project.org/ (PlanetMirror, Australia)
http://cran.br.R-project.org/ (Universidade Federal do Paraná, Brazil)
http://cran.ch.R-project.org/ (ETH Zürich, Switzerland)
http://cran.dk.R-project.org/ (SunSITE, Denmark)
http://cran.es.R-project.org/ (Spanish National Research Network, Madrid, Spain)
http://cran.fr.R-project.org/ (INRA, Toulouse, France)
http://cran.pt.R-project.org/ (Universidade do Porto, Portugal)
http://cran.uk.R-project.org/ (U of Bristol, United Kingdom)
http://cran.za.R-project.org/ (Rhodes U, South Africa)

See http://CRAN.R-project.org/mirrors.html for a complete list of mirrors. Please use the CRAN site closest to you to reduce network load.

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

To “submit” to CRAN, simply upload to ftp://CRAN.R-project.org/incoming/ and send an email to CRAN@R-project.org. Note that CRAN generally does not accept submissions of precompiled binaries due to security reasons. In particular, binary packages for Windows and Mac OS X are provided by the respective binary package maintainers.

Note: It is very important that you indicate the copyright (license) information (GPL-2, GPL-3, BSD, Artistic, ...) in your submission.

Please always use the URL of the master site when referring to CRAN.


Next: , Previous: What is CRAN?, Up: R Basics

2.11 Can I use R for commercial purposes?

R is released under the GNU General Public License (GPL). 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.

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 Open Source Definition:

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.

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

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.

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.

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


Next: , Previous: Can I use R for commercial purposes?, Up: R Basics

2.12 Why is R named R?

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 What is S?).


Previous: Why is R named R?, Up: R Basics

2.13 What is the R Foundation?

The R Foundation is a not for profit organization working in the public interest. It was founded by the members of the R Core Team in order to provide support for the R project and other innovations in statistical computing, provide a reference point for individuals, institutions or commercial enterprises that want to support or interact with the R development community, and to hold and administer the copyright of R software and documentation. See http://www.R-project.org/foundation/ for more information.


Next: , Previous: R Basics, Up: Top

3 R and S


Next: , Previous: R and S, Up: R and S

3.1 What is S?

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

the S system, which has forever altered the way people analyze, visualize, and manipulate data ...

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

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

See http://cm.bell-labs.com/cm/ms/departments/sia/S/history.html for further information on “Stages in the Evolution of S”.

There is a huge amount of user-contributed code for S, available at the S Repository at CMU.


Next: , Previous: What is S?, Up: R and S

3.2 What is S-Plus?

S-Plus is a value-added version of S sold by Insightful Corporation. Based on the S language, S-Plus 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.

See the Insightful S-Plus page for further information.


Next: , Previous: What is S-PLUS?, Up: R and S

3.3 What are the differences between R and S?

We can regard S as a language with three current implementations or “engines”, the “old S engine” (S version 3; S-Plus 3.x and 4.x), the “new S engine” (S version 4; S-Plus 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 engines.

For the remainder of this section, “S” refers to the S engines and not the S language.


Next: , Previous: What are the differences between R and S?, Up: What are the differences between R and S?

3.3.1 Lexical scoping

Contrary to other implementations of the S language, R has adopted an evaluation model in which nested function definitions are lexically scoped. This is analogous to the evalutation model in Scheme.

This difference becomes manifest when free 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). In S, the values of free variables are determined by a set of global variables (similar to C, there is only local and global scope). In R, they are determined by the environment in which the function was created.

Consider the following function:

     cube <- function(n) {
       sq <- function() n * n
       n * sq()
     }

Under S, sq() does not “know” about the variable n unless it is defined globally:

     S> cube(2)
     Error in sq():  Object "n" not found
     Dumped
     S> n <- 3
     S> cube(2)
     [1] 18

In R, the “environment” created when cube() was invoked is also looked in:

     R> cube(2)
     [1] 8

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

The S-Plus documentation for call() basically suggests the following:

     dorder <- function(n, r, pfun, dfun) {
       f <- function(x) NULL
       con <- round(exp(lgamma(n + 1) - lgamma(r) - lgamma(n - r + 1)))
       PF <- call(substitute(pfun), as.name("x"))
       DF <- call(substitute(dfun), as.name("x"))
       f[[length(f)]] <-
         call("*", con,
              call("*", call("^", PF, r - 1),
                   call("*", call("^", call("-", 1, PF), n - r),
                        DF)))
       f
     }

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

A version which makes heavy use of substitute() and seems to work under both S and R is

     dorder <- function(n, r, pfun, dfun) {
       con <- 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)))
     }

(the eval() is not needed in S).

However, in R there is a much easier solution:

     dorder <- function(n, r, pfun, dfun) {
       con <- 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)
       }
     }

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

Note that what you really need is the function closure, 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 MC() (for “make closure”):

     dorder <- function(n, r, pfun, dfun) {
       con <- 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))
     }

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

For R, MC() simply is

     MC <- function(f, env) f

(lexical scope!), a version for S is

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

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.

Nested lexically scoped functions allow using function closures and maintaining local state. A simple example (taken from Abelson and Sussman) is obtained by typing demo("scoping") at the R prompt. Further information is provided in the standard R reference “R: A Language for Data Analysis and Graphics” (see What documentation exists for R?) and in Robert Gentleman and Ross Ihaka (2000), “Lexical Scope and Statistical Computing”, Journal of Computational and Graphical Statistics, 9, 491–508.

Nested lexically scoped functions also imply a further major difference. Whereas S stores all objects as separate files in a directory somewhere (usually .Data 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 faster than S.

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 How can I save my workspace?) 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 source().

Note: If you run R from within Emacs (see R and Emacs), you can save the contents of the interaction buffer to a file and conveniently manipulate it using ess-transcript-mode, as well as save source copies of all functions and data used.


Next: , Previous: Lexical scoping, Up: What are the differences between R and S?

3.3.2 Models

There are some differences in the modeling code, such as


Previous: Models, Up: What are the differences between R and S?

3.3.3 Others

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.

Some known differences are the following.

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.


Next: , Previous: What are the differences between R and S?, Up: R and S

3.4 Is there anything R can do that S-Plus cannot?

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

R offers several graphics features that S-Plus 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 plotmath, 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”, Journal of Computational and Graphical Statistics, 9, 582–599.


Previous: Is there anything R can do that S-PLUS cannot?, Up: R and S

3.5 What is R-plus?

For a very long time, there was no such thing.

XLSolutions Corporation is currently beta testing a commercially supported version of R named R+ (read R plus).

In addition, REvolution Computing has released RPro, an enterprise-class statistical analysis system based on R, suitable for deployment in professional, commercial and regulated environments.

Random Technologies offers RStat, an enterprise-strength statistical computing environment which combines R with enterprise-level validation, documentation, software support, and consulting services, as well as related R-based products.


Next: , Previous: R and S, Up: Top

4 R Web Interfaces

Rweb is developed and maintained by Jeff Banfield. The Rweb Home Page 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 URL is provided.

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 (http://www.jstatsoft.org/v04/i01/).

Ulf Bartel has developed R-Online, 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 http://osvisions.com/r-online/ for more information.

Rcgi is a CGI WWW interface to R by MJ Ray. It had the ability to use “embedded code”: you could mix user input and code, allowing the HTML 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. Currently, a modified version of Rcgi by Mai Zhou (actually, two versions: one with (bitmap) graphics and one without) as well as the original code are available from http://www.ms.uky.edu/~statweb/.

CGI-based web access to R is also provided at http://hermes.sdu.dk/cgi-bin/go/. There are many additional examples of web interfaces to R which basically allow to submit R code to a remote server, see for example the collection of links available from http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/StatCompCourse.

David Firth has written CGIwithR, an R add-on package available from CRAN. It provides some simple extensions to R to facilitate running R scripts through the CGI interface to a web server, and allows submission of data using both GET and POST methods. 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. David's paper “CGIwithR: Facilities for Processing Web Forms Using R” was published in the Journal of Statistical Software (http://www.jstatsoft.org/v08/i10/). The package is now maintained by Duncan Temple Lang and has a web page at http://www.omegahat.org/CGIwithR/.

Rpad, developed and actively maintained by Tom Short, provides a sophisticated environment which combines some of the features of the previous approaches with quite a bit of Javascript, allowing for a GUI-like behavior (with sortable tables, clickable graphics, editable output), etc.

Jeff Horner is working on the R/Apache Integration Project which embeds the R interpreter inside Apache 2 (and beyond). A tutorial and presentation are available from the project web page at http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/RApacheProject.

Rserve is a project actively developed by Simon Urbanek. It implements a TCP/IP server which allows other programs to use facilities of R. Clients are available from the web site for Java and C++ (and could be written for other languages that support TCP/IP sockets).

OpenStatServer is being developed by a team lead by Greg Warnes; it aims “to provide clean access to computational modules defined in a variety of computational environments (R, SAS, Matlab, etc) via a single well-defined client interface” and to turn computational services into web services.

Two projects use PHP to provide a web interface to R. R_PHP_Online by Steve Chen (though it is unclear if this project is still active) is somewhat similar to the above Rcgi and Rweb. R-php is actively developed by Alfredo Pontillo and Angelo Mineo and provides both a web interface to R and a set of pre-specified analyses that need no R code input.

webbioc is “an integrated web interface for doing microarray analysis using several of the Bioconductor packages” and is designed to be installed at local sites as a shared computing resource.

Finally, Rwui is a web application to to create user-friendly web interfaces for R scripts. All code for the web interface is created automatically. There is no need for the user to do any extra scripting or learn any new scripting techniques.


Next: , Previous: R Web Interfaces, Up: Top

5 R Add-On Packages


Next: , Previous: R Add-On Packages, Up: R Add-On Packages

5.1 Which add-on packages exist for R?


Next: , Previous: Which add-on packages exist for R?, Up: Which add-on packages exist for R?

5.1.1 Add-on packages in R

The R distribution comes with the following packages:

base
Base R functions (and datasets before R 2.0.0).
datasets
Base R datasets (added in R 2.0.0).
grDevices
Graphics devices for base and grid graphics (added in R 2.0.0).
graphics
R functions for base graphics.
grid
A rewrite of the graphics layout capabilities, plus some support for interaction.
methods
Formally defined methods and classes for R objects, plus other programming tools, as described in the Green Book.
splines
Regression spline functions and classes.
stats
R statistical functions.
stats4
Statistical functions using S4 classes.
tcltk
Interface and language bindings to Tcl/Tk GUI elements.
tools
Tools for package development and administration.
utils
R utility functions.
These “base packages” were substantially reorganized in R 1.9.0. The former base was split into the four packages base, graphics, stats, and utils. Packages ctest, eda, modreg, mva, nls, stepfun and ts were merged into stats, package lqs returned to the recommended package MASS, and package mle moved to stats4.


Next: , Previous: Add-on packages in R, Up: Which add-on packages exist for R?

5.1.2 Add-on packages from CRAN

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

ADaCGH
Analysis of data from aCGH experiments.
AER
Functions, data sets, examples and vignettes for the book “Applied Econometrics with R” by Christian Kleiber and Achim Zeileis, 2008, Springer-Verlag, New York.
AIS
Tools to look at the data (“Ad Inidicia Spectata”).
AMORE
A MORE flexible neural network package, providing the TAO robust neural network algorithm.
ARES
Allelic richness estimation, with extrapolation beyond the sample size.
AcceptanceSampling
Creation and evaluation of acceptance sampling plans,
AdMit
Adaptive mixture of Student t distributions.
AdaptFit
Adaptive semiparametic regression.
AlgDesign
Algorithmic experimental designs. Calculates exact and approximate theory experimental designs for D, A, and I criteria.
Amelia
Amelia II: a program for missing data.
AnalyzeFMRI
Functions for I/O, visualisation and analysis of functional Magnetic Resonance Imaging (fMRI) datasets stored in the ANALYZE format.
ArDec
Time series autoregressive decomposition.
BACCO
Bayesian Analysis of Computer Code Output. Contains approximator, calibrator, and emulator, for Bayesian prediction of complex computer codes, calibration of computer models, and emulation of computer programs, respectively.
BARD
Better Automated ReDistricting.
BAYSTAR
Bayesian analysis of threshold autoregressive models.
BB
Barzilai-Borwein spectral methods for solving nonlinear system of equations, and for optimizing nonlinear objective functions subject to simple constraints.
BCE
Bayesian Composition Estimator for sample (taxonomic) composition from biomarker data.
BHH2
Functions and data sets reproducing some examples in “Statistics for Experimenters II” by G. E. P. Box, J. S. Hunter, and W. C. Hunter, 2005, John Wiley and Sons.
BMA
Bayesian Model Averaging for linear models, generalizable linear models and survival models (Cox regression).
BPHO
Bayesian Prediction with High-order Interactions.
BayHaz
Functions for Bayesian Hazard rate estimation.
BayesTree
Bayesian methods for tree based models.
BayesValidate
Bayesian software validation using posterior quantiles.
Bchron
Create chronologies based on radiocarbon and non-radiocarbon dated depths.
Bhat
Functions for general likelihood exploration (MLE, MCMC, CIs).
BiasedUrn
Biased urn model distributions.
BioIDMapper
Mapping between BioIDs.
Biodem
A number of functions for biodemographycal analysis.
BiodiversityR
GUI for biodiversity and community ecology analysis.
Bolstad
Functions and data sets for the book “Introduction to Bayesian Statistics” by W. M. Bolstad, 2004, John Wiley and Sons.
BootCL
Bootstrapping test for chromosomal localization.
BootPR
Bootstrap prediction intervals and bias-corrected forecasting.
BradleyTerry
Specify and fit the Bradley-Terry model and structured versions.
Brobdingnag
Very large numbers in R.
BSDA
Data sets for the book “Basic Statistics and Data Analysis” by L. J. Kitchens, 2003, Duxbury.
BsMD
Bayes screening and model discrimination follow-up designs.
CCA
Canonical correlation analysis.
CDNmoney
Components of Canadian monetary aggregates.
CGIwithR
Facilities for the use of R to write CGI scripts.
CORREP
Multivariate correlation estimation.
COZIGAM
Constrained Zero-Inflated Generalized Additive Model.
CPE
Concordance probability estimates in survival analysis.
CTFS
The CTFS large plot forest dynamics analyses.
CVThresh
Level-dependent Cross-Validation Thresholding.
Cairo
Graphics device using cairographics library for creating high-quality PNG, PDF, SVG, PostScript output and interactive display devices such as X11.
CarbonEL
Carbon Event Loop.
CellularAutomaton
One-dimensional cellular automata.
ChainLadder
Mack- and Munich-chain-ladder methods for insurance claims reserving.
CircStats
Circular Statistics, from “Topics in Circular Statistics” by S. Rao Jammalamadaka and A. SenGupta, 2001, World Scientific.
CoCo
Graphical modeling for contingency tables using CoCo.
ComPairWise
Compare phylogenetic or population genetic data alignments.
CombMSC
Combined Model Selection Criteria.
CompetingRiskFrailty
Competing risk model with frailties for right censored survival data.
Containers
Object-oriented data structures including stack, queue, and binary search tree.
CoxBoost
Cox survival models by likelihood based boosting.
CreditMetrics
Functions for calculating the CreditMetrics risk model.
DAAG
Various data sets used in examples and exercises in “Data Analysis and Graphics Using R” by John H. Maindonald and W. John Brown, 2003.
DAAGbio
Data sets and functions, for demonstrations with expression arrays.
DAAGxtras
Data sets and functions additional to DAAG.
DBI
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.
DCluster
A set of functions for the detection of spatial clusters of diseases using count data.
DDHFm
Variance stabilization by Data-Driven Haar-Fisz (for microarrays).
DEA
Data Envelopment Analysis.
DEoptim
Differential Evolution Optimization.
DICOM
Import and manipulate medical imaging data using the Digital Imaging and Communications in Medicine (DICOM) Standard.
DPpackage
Semiparametric Bayesian analysis using Dirichlet process priors.
Davies
Functions for the Davies quantile function and the Generalized Lambda distribution.
Defaults
Create global function defaults.
DescribeDisplay
R interface to the DescribeDisplay GGobi plugin.
Design
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.
Devore5
Data sets and sample analyses from “Probability and Statistics for Engineering and the Sciences (5th ed)” by Jay L. Devore, 2000, Duxbury.
Devore6
Data sets and sample analyses from “Probability and Statistics for Engineering and the Sciences (6th ed)” by Jay L. Devore, 2003, Duxbury.
Devore7
Data sets and sample analyses from “Probability and Statistics for Engineering and the Sciences (7th ed)” by Jay L. Devore, 2008, Thomson.
DierckxSpline
R companion to “Curve and Surface Fitting with Splines” by Paul Dierckx, 1993, Oxford University Press.
EDR
Estimation of the effective dimension reduction (EDR) space.
EMC
Evolutionary Monte Carlo (EMC) algorithm.
EMCC
Evolutionary Monte Carlo (EMC) methods for clustering.
EMD
Empirical mode decomposition and Hilbert spectral analysis.
EMV
Estimation of missing values in a matrix by a k-th nearest neighboors algorithm.
ETC
Tests and simultaneous confidence intervals for equivalence to control.
EbayesThresh
Empirical Bayes thresholding and related methods.
Ecdat
Data sets from econometrics textbooks.
EffectiveDose
Estimate the effective dose level for quantal bioassay data by nonparametric techniques.
ElemStatLearn
Data sets, functions and examples from the book “The Elements of Statistical Learning: Data Mining, Inference, and Prediction” by Trevor Hastie, Robert Tibshirani and Jerome Friedman (2001), Springer.
Epi
Statistical analysis in epidemiology, with functions for demographic and epidemiological analysis in the Lexis diagram.
FAiR
Factor Analysis in R, using genetic algorithms.
FGN
Fractional Gaussian Noise model fitting.
FKBL
Fuzzy Knowledge Base Learning.
FTICRMS
Analysis of Fourier Transform-Ion Cyclotron Resonance Mass Spectrometry data.
FactoMineR
Factor analysis and data mining with R.
Fahrmeir
Data from the book “Multivariate Statistical Modelling Based on Generalized Linear Models” by Ludwig Fahrmeir and Gerhard Tutz (1994), Springer.
FieldSim
Random fields simulations.
FinTS
Companion to the book “Analysis of Financial Time Series” by Ruey Tsay (2005), Wiley (2nd edition).
FitAR
Subset AR model fitting.
Flury
Data sets from from “A First Course in Multivariate Statistics” by Bernard Flury (1997), Springer.
FrF2
Analysis of fractional factorial designs with 2-level factors.
FracSim
Simulation of one- and two-dimensional fractional and multifractional Levy motions.
FunCluster
Functional profiling of cDNA microarray expression data.
FunNet
Functional analysis of gene co-expression networks.
G1DBN
Dynamic Bayesian Network inference using 1st order conditional dependencies.
GAMBoost
Generalized additive models by likelihood based boosting.
GDD
Platform and X11 independent device for creating bitmaps (png, gif and jpeg) using the GD graphics library.
GEOmap
Topographic and geologic mapping.
GLDEX
Fit RS and FMKL generalised lambda distributions using discretized and maximum likelihood methods.
GOSim
Computation of functional similarities between GO terms and gene products.
GPArotation
Gradient Projection Algorithm rotation for factor analysis.
GRASS
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.
GSA
Gene set analysis.
GSM
Gamma Shape Mixture.
GenABEL
Genome-wide SNP association analysis.
GenKern
Functions for generating and manipulating generalised binned kernel density estimates.
GeneCycle
Identification of periodically expressed genes.
GeneF
Generalized F-statistics.
GeneNT
Relevance or Dependency network and signaling pathway discovery.
GeneNet
Modeling and inferring gene networks.
GeneTS
A package for analysing multiple gene expression time series data. Currently, implements methods for cell cycle analysis and for inferring large sparse graphical Gaussian models.
Geneland
MCMC inference from individual genetic data based on a spatial statistical model.
GeoXp
Interactive exploratory spatial data analysis.
GillespieSSA
Gillespie's Stochastic Simulation Algorithm (SSA).
GroupSeq
Computations related to group-seqential boundaries.
HH
Support software for “Statistical Analysis and Data Display” by Richard M. Heiberger and Burt Holland, Springer, 2005.
HI
Simulation from distributions supported by nested hyperplanes.
HSAUR
Functions, data sets, analyses and examples from the book “A Handbook of Statistical Analyses Using R” by Brian S. Everitt and Torsten Hothorn (2006), Chapman & Hall/CRC.
HTMLapplets
Functions inserting dynamic scatterplots and grids in documents generated by R2HTML.
HFWutils
Utilities by H. Felix Wittmann: Excel connections, string matching, and passing by reference.
HardyWeinberg
Graphical tests for Hardy-Weinberg equilibrium.
HiddenMarkov
Hidden Markov Models.
Hmisc
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.
HydroMe
Estimation of soil hydraulic parameters from experimental data.
HyperbolicDist
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.
IBrokers
R API to Interactive Brokers Trader Workstation.
ICE
Iterated Conditional Expectation: kernel estimators for interval-censored data.
ICEinfer
Incremental Cost-Effectiveness (ICE) statistical inference (from two unbiased samples).
ICS
ICS/ICA computation based on two scatter matrices.
ICSNP
Tools for multivariate nonparametrics.
IDPmisc
Utilities from the Institute of Data Analyses and Process Design, IDP/ZHW.
ISA
Functions to support “Introduzione alla Statistica Applicata con esempi in R” by Federico M. Stefanini, Pearson Education Milano, 2007.
ISOcodes
ISO language, territory, currency, script and character codes.
ISwR
Data sets for “Introductory Statistics with R” by Peter Dalgaard, 2002, Springer.
Icens
Functions for computing the NPMLE for censored and truncated data.
Iso
Functions to perform isotonic regression.
JADE
JADE and ICA performance criteria.
JGR
Java Gui for R.
JM
Joint Modeling of longitudinal and survival data.
JavaGD
Java Graphics Device.
JointGLM
Joint modeling of mean and dispersion through two interlinked GLM's. Defunct in favor of JointModeling.
JointModeling
Joint modeling of mean and dispersion.
JudgeIt
Calculates bias, responsiveness, and other characteristics of two-party electoral systems, with district-level electoral and other data.
KMsurv
Data sets and functions for “Survival Analysis, Techniques for Censored and Truncated Data” by Klein and Moeschberger, 1997, Springer.
Kendall
Kendall rank correlation and Mann-Kendall trend test.
KernSmooth
Functions for kernel smoothing (and density estimation) corresponding to the book “Kernel Smoothing” by M. P. Wand and M. C. Jones, 1995. Recommended.
LDheatmap
Heat maps of linkage disequilibrium measures.
LDtests
Exact tests for linkage disequilibrium and Hardy-Weinberg equilibrium.
LIStest
Longest increasing subsequence independence test.
LLAhclust
Hierarchical clustering of variables or objects based on the likelihood linkage analysis method.
LLN
Learning with latent networks.
LMGene
Date transformation and identification of differentially expressed genes in gene expression arrays.
LearnBayes
Functions for Learning Bayesian Inference.
Lmoments
Estimation of L-moments and the parameters of normal and Cauchy polynomial quantile mixtures.
LogConcDEAD
Maximum likelihood estimation of a log-concave density.
LogicReg
Routines for Logic Regression.
LoopAnalyst
A collection of tools to conduct Levins' Loop Analysis.
LowRankQP
Low Rank Quadratic Programming: QP problems where the hessian is represented as the product of two matrices.
MASS
Functions and datasets from the main package of Venables and Ripley, “Modern Applied Statistics with S”. Contained in the VR bundle. Recommended.
MBA
Multilevel B-spline Approximation.
MBESS
Methods for the Behavioral, Educational, and Social Sciences.
MCMCpack
Markov chain Monte Carlo (MCMC) package: functions for posterior simulation for a number of statistical models.
MCPAN
Multiple comparisons using normal approximation.
MCPMod
Design and analysis of dose-finding studies.
MChtest
Monte Carlo hypothesis tests.
MEMSS
Data sets and sample analyses from “Mixed-effects Models in S and S-PLUS” by J. Pinheiro and D. Bates, 2000, Springer.
MFDA
Model Based Functional Data Analysis.
MKLE
Maximum kernel likelihood estimation.
MLDA
Methylation Linear Discriminant Analysis (MLDA).
MLDS
Maximum Likelihood Difference Scaling.
MLEcens
Computation of the MLE for bivariate (interval) censored data.
MMG
Mixture Model on Graphs.
MNP
Fitting Bayesian Multinomial Probit models via Markov chain Monte Carlo. Along with the standard Multinomial Probit model, it can also fit models with different choice sets for each observation and complete or partial ordering of all the available alternatives.
MPV
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.
MSBVAR
Bayesian vector autoregression models, impulse responses and forecasting.
MarkedPointProcess
Non-parametric analysis of the marks of marked point processes.
MasterBayes
Maximum likelihood and Markov chain Monte Carlo methods for pedigree reconstruction, analysis and simulation.
MatchIt
Select matched samples of the original treated and control groups with similar covariate distributions.
Matching
Multivariate and propensity score matching with formal tests of balance.
Matrix
A Matrix package.
MiscPsycho
Miscellaneous Psychometrics.
MultEq
Equivalence tests and simultaneous confidence intervals for multiple endpoints.
NADA
Methods described in “Nondetects And Data Analysis: Statistics for Censored Environmental Data” by Dennis R. Helsel, 2004, John Wiley and Sons.
NISTnls
A set of test nonlinear least squares examples from NIST, the U.S. National Institute for Standards and Technology.
NMMAPSlite
U.S. National Morbidity, Mortality, and Air Pollution Study data lite.
NORMT3
Evaluates complex erf, erfc and density of sum of Gaussian and Student's t.
NRAIA
Data sets with sample code from “Nonlinear Regression Analysis and Its Applications” by Doug Bates and Donald Watts, 1988, Wiley.
NestedCohort
Survival analysis for cohorts with missing covariate information.
ORMDR
Odds ratio based multivactor-dimensionality reduction method for detecting gene-gene interactions.
Oarray
Arrays with arbitrary offsets.
PARccs
Estimation of partial attributable risks (PAR) from case-control data.
PASWR
Data and functions for the book “Probability and Statistics with R” by M. D. Ugarte, A. F. Militino and A. T. Arnholt, 2008, Chapman & Hall/CRC.
PBSmapping
Software evolved from fisheries research conducted at the Pacific Biological Station (PBS) in Nanaimo, British Columbia, Canada. Draws maps and implements other GIS procedures.
PBSmodelling
Software to facilitate the design, testing, and operation of computer models.
PET
Simulation and reconstruction of PET images.
PHYLOGR
Manipulation and analysis of phylogenetically simulated data sets (as obtained from PDSIMUL in package PDAP) and phylogenetically-based analyses using GLS.
PK
Estimation of pharmacokinetic parameters.
PKfit
A nonlinear regression (including a genetic algorithm) program designed to deal with curve fitting for pharmacokinetics.
Unified computational interfaces for pop PK.
POT
Generalized Pareto distribution and Peaks Over Threshold.
PSAgraphics
Propensity Score Analysis Graphics.
PSM
Non-linear mixed-effects modeling using stochastic differential equations.
PTAk
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.
Peaks
Spectrum manipulation: background estimation, Markov smoothing, deconvolution and peaks search functions.
PearsonICA
Independent component analysis using score functions from the Pearson system.
PerformanceAnalytics
Econometric tools for performance and risk analysis.
PhySim
Phylogenetic tree simulation.
PolynomF
Univariate polynomials.
Pomic
Pattern oriented modeling information criterion.
PresenceAbsence
Presence-absence model evaluation.
ProbForecastGOP
Probabilistic weather field forecasts using the Geostatistical Output Perturbation method introduced by Gel, Raftery and Gneiting (2004).
ProbeR
Reliability for gene expression from Affymetrix chip.
ProfessR
Programs to determine student grades and create examinations from question banks.
PtProcess
Time dependent point process modeling.
PwrGSD
Power in a Group Sequential Design.
QCA
Qualitative Comparative Analysis for crisp sets.
QCAGUI
QCA Graphical User Interface.
QRMlib
Code to examine Quantitative Risk Management concepts.
QuantPsyc
Quantitative Psychology tools.
R.cache
Fast and light-weight caching of objects.
R.huge
Methods for accessing huge amounts of data.
R.matlab
Read and write of MAT files together with R-to-Matlab connectivity.
R.methodsS3
Utility functions for defining S3 methods.
R.oo
R object-oriented programming with or without references.
R.rsp
R server pages.
R.utils
Utility classes and methods useful when programming in R and developing R packages.
R2HTML
Functions for exporting R objects & graphics in an HTML document.
R2WinBUGS
Running WinBUGS from R: call a BUGS model, summarize inferences and convergence in a table and graph, and save the simulations in arrays for easy access in R.
RArcInfo
Functions to import Arc/Info V7.x coverages and data.
RBGL
Interface to the boost C++ graph library.
RBloomberg
Fetch data from a Bloomberg API using COM.
RColorBrewer
ColorBrewer palettes for drawing nice maps shaded according to a variable.
RDieHarder
R interface to the dieharder random number generator test suite.
RExcelInstaller
Integration of R and Excel under MS Windows.
RFA
Regional Frequency Analysis.
RFOC
Graphics for spherical distributions and earthquake focal mechanisms.
RFreak
An R interface to a modified version of the Free Evolutionary Algorithm Kit FrEAK.g
RGtk2
Facilities for programming graphical interfaces using Gtk (the Gimp Tool Kit) version 2.
RGrace
Mouse/menu driven interactive plotting application.
RGraphics
Data and functions from the book “R Graphics” by Paul Murrell, 2005, Chapman & Hall/CRC.
RHmm
Hidden Markov Model simulations and estimations.
RII
Estimation of the relative index of inequality for interval-censored data using natural cubic splines.
RJDBC
Access to databases through the JDBC interface.
RJaCGH
Reversible Jump MCMC for the analysis of CGH arrays.
RLMM
A genotype calling algorithm for Affymetrix SNP arrays.
RLRsim
Exact (Restricted) Likelihood Ratio tests for mixed and additive models.