R packages for the base system have been part of the Debian distribution
since 1997. R, as well as many add-on packages (from CRAN and others
repositories) are available via the regular Debian distribution mechanisms.
Hence, running
apt-cache search ^r-.*
should get you started with a list of available packages.
After a release of Debian "stable", no new packages get added by Debian to
keep the release as 'stable' as possible. This implies that the R release
contained in the official Debian release will become outdated as time passes.
As a courtesy to the R users on the Debian "stable" platforms, the "stable"
directory on CRAN contains so-called 'backports' of the current R binaries
for the "stable" distribution of Debian.
For a backport of the latest R release to squeeze, simply add something like
to the file /etc/apt/sources.list on your computer and install as
usual. Note that you need to substitute <favorite-cran-mirror> by one of the
mirror URLs listed in
With an appropriate entry in /etc/apt/sources.list, the newest R release can be
installed using a command sequence like
apt-get update
apt-get install r-base r-base-dev
While updating your package lists you might get a warning about a missing key,
telling you that the integrity of packages can not be verified. You can ignore
this if you trust the CRAN servers and continue with the installation.
Otherwise, please refer to the section on secure apt below.
You only need r-base-dev if you want to compile R packages yourself or other
software depending on R (see section below on administration and maintenance).
Be aware that you may also have to install build dependencies (typically -dev
packages containing headers). The list r-sig-debian is a good place to ask if
you run into problems.
Special note for R 2.14.0: After installing R 2.14.0 or greater, some packages
that are present on your system may fail to load, if they do not contain a
namespace and if they were installed using a prior version. Reinstalling them
from a source package will solve the problem. See the first entry for R 2.14.0
in http://cran.r-project.org/src/base/NEWS.html
to the file /etc/apt/sources.list on your computer and install as
usual. There are binaries for the i386 and amd64 architectures. You
can use the source packages from
to compile binaries for other platforms. Please be aware that lenny is not
supported by the Debian security team any more. The newest R backport for lenny
is 2.14.1.
Note for R versions starting from 2.11.0: After installing a version greater
than R 2.10.X from CRAN, you will have to update or reinstall all R packages
that have been installed with an R version lower than R 2.10.X, as they will
not work with the new help system. This will be the case for any r-cran-*
debian packages from the lenny distribution that you may still be using.
Before R 2.12.2, when squeeze was not released yet, I proposed apt-pinning for
installing up-to-date R packages from unstable (sid) on squeeze by creating a
file /etc/apt/preferences containing
and adding a line for unstable in /etc/apt/sources.list. As the new testing
distribution with codename wheezy is not frozen, you can remove or uncomment
these entries, except if you want to have the latest R version on wheezy before
it migrates from unstable to testing.
A number of R packages are available from the Debian repositories with
names starting with r-cran-. Note, however, that only the packages
part of the r-recommended set are kept up-to-date on CRAN.
Currently, these are:
The Debian backports archives on CRAN are signed with the key of "Johannes
Ranke (CRAN Debian archive) <jranke@uni-bremen.de>" with key ID 381BA480.
You can fetch this with
If this doesn't work, it might be due to a firewall blocking port 11371.
Alternatively, you can search for 0x381BA480 at http://keyserver.noreply.org/
and copy the key block into a plain text file, named, for instance,
jranke_cran.asc.
If receiving the key with gpg did work, you need to export it to a text file
gpg -a --export 381BA480 > jranke_cran.asc
In both cases you need to make the key known to the apt system by running
The R packages part of the r-base and r-recommended packages are installed into
the directory /usr/lib/R/library. These can be updated using usual package
maintenance tools like apt-get or aptitude.
The other R packages precompiled as Debian packages r-cran-* are
installed into /usr/lib/R/site-library.
The command
apt-cache rdepends r-base-core
shows all packages that depend on r-base-core; this comprises a large number of
contributed packages from CRAN and other repositories.
If you want to install R packages not provided as Debian packages, or if you want
to use newer versions, you need to build them from source which requires the
development package r-base-dev that can be installed by
apt-get install r-base-dev
This makes sure that you have the basic requirements for compiling R
packages. R packages may then be installed by the local user/admin from the
CRAN source packages, typically from inside R using the
> install.packages()
function or using R CMD INSTALL from a shell. If you have proper write permissions
in /usr/local/lib/R/site-library/, and you have not set R_LIBS_USER manually,
they will be installed there. Otherwise, you will be asked if a directory in
your home directory should be created for these packages. A routine update of
such locally compiled packages can be done using
> update.packages(.libPaths()[1])
which will update the packages in the first part of your library path. You can have
a look at the components of this part by
> libPaths()
If you would like to update R packages that have been installed via the Debian package
management system which are installed somewhere under /usr/lib/, I would
recommend to do this the Debian way using the source packages from Debian unstable.
This means that packages installed from within R take precedence over the ones installed
via the Debian package management system if you happen to have two versions installed
at the same time.
Anyone interested in building Debian packages (e.g. for an unsupported release,
another architecture or an old R version) can have a look at the build scripts
used by the current maintainer. These are available anonymously from the
Subversion repository
The Debian R packages are maintained by Dirk Eddelbuettel. The packages present
on CRAN for Debian stable and oldstable are provided by Johannes Ranke.