R packages for the base system have been part of the Debian distribution since 1997, thanks to Douglas Bates, and are diligently maintained by Dirk Eddelbuettel since 2001. 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 R 3.0.2 to wheezy, simply add something like
deb http://<favorite-cran-mirror>/bin/linux/debian wheezy-cran3/
to the file /etc/apt/sources.list on your computer. You need to substitute <favorite-cran-mirror> by one of the mirror URLs listed in
Please be aware that the R packages available as binary .deb packages in wheezy (with names starting with r-cran-) are not compatible with R 3.0.x. Only a confined number of binary packages is provided here.
Before installing R 3.0.x you should make sure you do not rely on loading R packages available from Debian wheezy. If unsure, look at the debs you have installed using
dpkg --get-selections | grep r-cran
and compare with the list of packages supported below.
Updating packages installed locally from sources, which you need to do after an upgrade to R 3.0, is explained below under the section administration and maintenance. What you probably need to do is
> update.packages(.libPaths(), checkBuilt=TRUE)
in order to rebuild packages that are installed in addition to the Debian r-cran-* packages. For other changes in R see http://cran.r-project.org/src/base/NEWS.html.
The packages recommended by the R core team (r-recommended) are supported on CRAN. Currently, these are:
r-cran-boot r-cran-cluster r-cran-class r-cran-codetools r-cran-foreign r-cran-kernsmooth r-cran-lattice r-cran-mass r-cran-matrix r-cran-mgcv r-cran-nlme r-cran-nnet r-cran-rmatrix r-cran-rpart r-cran-spatial r-cran-survival
Because they rely on the installed version of R, backports of the following packages are also supplied.
littler r-cran-rodbc python-rpy python-rpy2 rkward r-cran-jags r-cran-coda (needed for r-cran-rjags)
The milestone release R 3.0.0 published on April 3, 2013 is not compatible with any R packages built on earlier versions. This means that R packages from the Debian squeeze archive do not work under R 3.0.x (as noted for wheezy at the top of this README). In order to avoid breaking production systems using the R backports from CRAN plus such Debian stable binary packages, the backport of R 3.0.x to Debian squeeze is published in a different location from what whas used before. This is the source line needed for R 3.0.x on Debian squeeze
deb http://<favorite-cran-mirror>/bin/linux/debian squeeze-cran3/
Again, you need to substitute <favorite-cran-mirror> by one of the mirror URLs listed in
Of course the R packages r-cran-* provided here are compiled using R 3.0.x. Before installing R 3.0.x be sure you do not rely on loading R packages from Debian squeeze. If unsure, look at the debs you have installed using
dpkg --get-selections | grep r-cran
and compare with the list of packages supported here (see above, also for a procedure to upgrade packages install locally from source R packages).
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.
You may want to install the automatically tuned Atlas or the multi-threaded OpenBlas library in order to get higher performance for linear algebra operations
apt-get install libatlas3-base
apt-get install libopenblas-base
There are binaries for i386 and amd64. In addition, I have uploaded binaries for the armel architecture. However, you need to take care of your LANG environment variable and lazyloading of datasets does not work, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=695411.
For other architectures, you can use the source packages from one of the repositories
deb-src http://<favorite-cran-mirror>/bin/linux/debian squeeze-cran/ deb-src http://<favorite-cran-mirror>/bin/linux/debian squeeze-cran3/ deb-src http://<favorite-cran-mirror>/bin/linux/debian wheezy-cran3/
to compile binaries. Note that you need to install current versions of debhelper and dpkg-dev in order to build r-cran-rjags from the source package provided in the latter location.
The Debian backports archives on CRAN are signed with the key of "Johannes Ranke (CRAN Debian archive) <email@example.com>" with key ID 381BA480. You can fetch and import this with
apt-key adv --keyserver subkeys.pgp.net --recv-key 381BA480
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 wich you add to apt with apt-key add.
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.
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
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
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
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.
In order to find packages, R looks at the variables R_LIBS_USER and R_LIBS_SITE. On Debian and Ubuntu, R_LIBS_USER is set in /etc/R/Renviron to
where $platform is something like 'x86_64-pc-linux-gnu'. You can override this in ~/.Renviron. R_LIBS_SITE is set in /etc/R/Renviron to
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.
The best place to report problems with these packages or ask R questions specific to Debian is the R-SIG-Debian mailing list. See
for more information.
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 scripts contain some small changes needed to compile the original Debian packages on the supported release. Note that I did install up to date versions of debhelper and dpkg-dev in the build system for the backports to squeeze.
The Debian R packages are maintained by Dirk Eddelbuettel. The packages present on CRAN for Debian stable and oldstable are provided by Johannes Ranke.