Packages for the base R 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-.*" | sort
in a shell should get you started with a list of available packages.
With an appropriate entry in
/etc/apt/sources.list (see below for Debian branches other than sid/unstable), 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
r-recommended 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 available as precompiled Debian packages
r-bioc-* are installed into
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 pulls in 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 path 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_SITE. On Debian and Ubuntu,
R_LIBS_USER is set in
$platform is something like
'x86_64-pc-linux-gnu' and depending on the version of R installed. You can override this in
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.
As R and related packages are currently not part of the official Debian backports repositories like
jessie-backports (please contact r-sig-debian if you would like to change this), the R versions in released or frozen Debian releases get out of date. Therefore, updates of a subset of these R related packages are provided here for such Debian releases.
The packages recommended by the R core team (
r-recommended) are updated on CRAN upon each new release of R. Currently, these are:
r-cran-boot r-cran-class r-cran-cluster 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 rkward r-cran-jags (wheezy and jessie only, entailing backports of jags and r-cran-coda)
A backport of the current
python-rpy2 package to wheezy (oldstable) would require a backport of python-singledispatch, which appears to be a bit tricky. Some help would be needed to bring this back. As of the backport of R 3.2.1, I did not even manage to build python-rpy2 packages for jessie any more.
For a backport of R 3.3.1 to jessie, simply add something like
deb http://<favourite-cran-mirror>/bin/linux/debian jessie-cran3/
to the file
/etc/apt/sources.list on your computer. You need to substitute
<favourite-cran-mirror> by one of the mirror URLs listed in the mirror list.
The last R release backported to wheezy and made available on CRAN is currently R 3.2.5 with the codename “Very, Very Secure Dishes”. Backporting R 3.3.0 and later would entail backporting curl 7.28 to wheezy, which in turn would require libgnutla28-dev (which is available in wheezy-backports), linghttp2-dev (only available in jessie) and librtmp-dev >= 2.4+20131018.git (not available in wheezy).
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 wheezy archive do not work under R 3.x.y. This is the source line needed for R 3.x.y on Debian wheezy
deb <favourite-cran-mirror>/bin/linux/debian wheezy-cran3/
Again, you need to substitute
<favourite-cran-mirror> by one of the mirror URLs listed in the mirror list.
Of course the R packages
r-cran-* provided here are compiled using the current R version. Before installing R 3.x.y be sure you do not rely on loading R packages 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 here (see above, also for a procedure to upgrade packages install locally from source R packages).
This repository also contains backports of tcl8.6, tk8.6 and texinfo for wheezy, as the upstream Debian package of R >= 3.2.0 need these versions.
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 versions 3.0.0 and later. Only a confined number of R packages is provided here.
Updating packages installed locally from sources, which you need to do after an upgrade from R 2.a.b to R 3.x.y, is explained below under the section administration and maintenance. What you probably need to do is
R> update.packages(.libPaths(), checkBuilt=TRUE)
in R in order to rebuild packages that are installed in addition to the Debian
r-cran-* packages. For other changes in R please refer to the NEWS file.
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://keys.gnupg.net 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 and wheezy. Since R 3.1.0, R is fully functional on arm and armel binaries for jessie and wheezy are provided here as well.
For other architectures, you can use the source packages from one of the repositories
deb-src <favourite-cran-mirror>/bin/linux/debian wheezy-cran3/ deb-src <favourite-cran-mirror>/bin/linux/debian jessie-cran3/
to compile binary Debian packages.
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 can be inspected at
or cloned from the git repository
git clone http://cgit.jrwb.de/r-backports
The scripts contain some small changes needed to compile the original Debian packages on the supported release.
The following notes are an attempt to merge the hints given in a thread on r-sig-debian started end of March 2015, and the tips given at https://developer.r-project.org/SVNtips.html. I have not used this a lot and I assume you have some experience in building software on unix systems. No warranties, your mileage may vary.
First, make sure you have a source repository in your
deb-src <favourite-cran-mirror>/bin/linux/debian jessie-cran3/
in order to make it easier to get the build dependencies. Then update your list of available packages and run as root
apt-get build-dep r-base
To install the build dependencies. The following commands do not need root privileges, and are safer to run as a normal user.
I keep all sources managed by subversion under
~/svn, so I do
Please adapt to your needs. The location of the source code for the base R system is conveniently defined as en environment variable by
We change to our RTOP directory and check out the latest revision of R-devel
cd $RTOP svn co $REPOS/trunk r-devel/source mkdir $RTOP/r-devel/build
The second time around we only need to
cd $RTOP/r-devel/source svn up
Then we need to get the sources of the recommended packages
cd $RTOP/r-devel/source/tools ./rsync-recommended
We build in the separate directory created above, in order not to pollute the source code
cd $RTOP/r-devel/build ../source/configure
There are a lot of configure options you might want to use. However, we are not using the install target here, so we do not set
--prefix. This is to avoid conflicts with the Debian packages of released versions of R. The next step builds the sources.
make make check make pdf make info
Of course doing checks and making pdf and info documentation is optional. Then we use links to make R-devel and Rscript-devel available (obviously supposes write permission on /usr/local/bin).
cd /usr/local/bin ln -s /$RTOP/r-devel/build/bin/R R-devel ln -s /$RTOP/r-devel/build/bin/Rscript Rscript-devel
This will make the commands
Rscript-devel available. Note that the only entry on
$RTOP/r-devel/build/library, so this is where packages will be installed.
After the release of a version R-x.y.0, the so-called release branch is used to introduce changes that meet the development guidelines.
We can build such branches (aka R-patched) using the following scheme, which is adapted from the procedure given for R-devel, but without duplicating all comments.
At the time of this writing, the release branch can be defined by
R-patched can than be built and made available by
cd $RTOP svn co $REPOS/$RPATCHED r-patched/source mkdir $RTOP/r-patched/build cd $RTOP/r-patched/source/tools ./rsync-recommended
Again, we build in the separate directory created above, in order not to pollute the source code
cd $RTOP/r-patched/build ../source/configure make make check make pdf make info
Then, as privileged user:
cd /usr/local/bin ln -s /$RTOP/r-patched/build/bin/R R-patched ln -s /$RTOP/r-patched/build/bin/Rscript Rscript-patched
The builds can be updated by updating the sources from the repository, syncing the latest versions of the recommended packages and rebuilding.
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.