Installing R and RStudio in Ubuntu 12.04
Universe
The current version of R available when a new version of Ubuntu is released is always available in the universe repository. To install R:
sudo apt-get install r-base r-base-dev
This will install R, the recommended packages, and files needed to install many additional packages (but not all) from within R using install.packages(“foo”). The R packages found in the universe repository are not updated when new versions of R or the recommended packages are released.
CRAN
CRAN has current versions of R and the recommended packages available for all currently supported versions of Ubuntu. Detailed instructions for adding the CRAN repositories can be found here. The first step is to add the security key:
sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys E084DAB9
Then you need to add the CRAN repository to end of /etc/apt/sources.list:
deb http://cran.r-project.org/bin/linux/ubuntu precise/
R can then be installed:
sudo apt-get update sudo apt-get install r-base r-base-dev
The packages on CRAN are updated on a regular basis and the most recent versions will be usually be available within a couple days of their release.
One advantage of using the CRAN repository is that older versions of packages are available. To install an older version of a package, it must be pinned. Directions for pinning are different for apt-get and synaptic and details can be found here.
Launchpad PPA
Packages for the CRAN repository are built on a Launchpad PPA called RutteR. It is possible to use the PPA itself, which includes a few more packages than the CRAN repository (JAGS and related packages, for example). Installing the PPA via apt is very simple:
sudo add-apt-repository ppa:marutter/rrutter sudo apt-get update sudo apt-get install r-base r-base-dev
The PPA is updated slightly quicker than the CRAN repository, but older packages are not available.
If you have any questions about the CRAN or PPA repositories, please email the maintainer Michael Rutter
.
RStudio
RStudio is a set of integrated tools designed to help you be more productive with R. It includes a console, syntax-highlighting editor that supports direct code execution, as well as tools for plotting, history, debugging and workspace management.
Download the zip/tarball package for RStudio -RStudio 0.99.485 - Ubuntu 12.04+/Debian 8+ (64-bit) from the website https://www.rstudio.com/products/rstudio/download/
Copy the package rstudio-xx.xx.xx-amd64-debian.tar.gz
in the desired location and run the tar
command to decompress the package
tar -xvf rstudio-xx.xx.xx-amd64-debian.tar.gz
To launch RStudio execute the binary in the package directory
bin/rstudio
References
- http://sites.psu.edu/theubunturblog/installing-r-in-ubuntu/
- http://www.r-bloggers.com/download-and-install-r-in-ubuntu/