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.
With an appropriate entry in
(see below according to the branch of Debian used), the newest R
release including recommended packages 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
The R packages part of the
r-recommended packages are installed into the
/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
r-cran-* are installed
apt-cache rdepends r-base-core
shows all packages that depend on
comprises a large number of contributed packages from CRAN and
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
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
/usr/local/lib/R/site-library/, and you have not
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
/usr/lib/, I would recommend to do
this the Debian way using the source packages from Debian
In order to find packages, R looks at the
R_LIBS_SITE. On Debian and
R_LIBS_USER is set
$platform is something
'x86_64-pc-linux-gnu'. You can override this
R_LIBS_SITE is set in
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 packages recommended by the R core team
r-recommended) are supported on CRAN. Currently,
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-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)
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.1.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
are not compatible with R 3.x.x. Only a confined number of binary
packages is provided here.
Before installing R 3.x.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 from R 2.x.y to R 3.x.y, 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
r-cran-* packages. For other changes in R
As of end of January 2015, there is a new repository containing binaries for Jessie (current testing). This repository hosts all supported packages presented above, and is updated upon new R releases.
To use R supported packages on Debian Jessie, simply add something like
deb http://<favorite-cran-mirror>/bin/linux/debian jessie-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
Alternatively, it is possible to use APT-pining to install only
R-related packages from SID using Debian official repositories
(Warning: should be reserved to advanced users already
familiar with pinning their Debian system). Simply add the
supported packages (and other
r-cran-* of interest)
/etc/apt/preferences with a priority greater or
equal than the priority of regular testing packages:
Package: r-base r-base-core r-base-dev r-recommended 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-rpart r-cran-spatial r-cran-survival littler r-cran-rodbc python-rpy python-rpy2 rkward r-cran-jags r-cran-coda Pin: release o=Debian,a=unstable,l=Debian Pin-Priority: 900
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.x.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.x.x to Debian squeeze is published in a different location from what whas used before. This is the source line needed for R 3.x.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.x.x. Before installing R 3.x.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).
The latest stable versions of R and R packages are readily available in official Debian SID repositories.
The Debian backports archives on CRAN are signed with the key of "Johannes Ranke (CRAN Debian archive) <firstname.lastname@example.org>" with key ID 381BA480. You can fetch and import this with
apt-key adv --keyserver keys.gnupg.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.
There are i386 and amd64 binaries for jessie, wheezy, squeeze. Since R 3.1.0, R is fully functional on arm and armel binaries for jessie and wheezy are provided here as well.
Before R 3.1.0 lazyloading of datasets did not work on arm, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=695411. Thanks to Orion Poplawski from the Fedora project, among others, these issues are now fixed, see https://bugs.r-project.org/bugzilla/show_bug.cgi?id=15087.
For other architectures, you can use the source packages from one of the repositories
deb-src http://<favorite-cran-mirror>/bin/linux/debian squeeze-cran3/ deb-src http://<favorite-cran-mirror>/bin/linux/debian wheezy-cran3/ deb-src http://<favorite-cran-mirror>/bin/linux/debian jessie-cran3/
to compile binaries. Note that you need to install current
order to build
r-cran-rjags from the source package
provided in the latter location.
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. Thanks to Mathieu Basille for restructuring the README in March 2015.