The purpose of this note is to provide, in the Ubuntu Forums, a concise outline of how to install R and RStudio.
Feeling a need to refresh and update myself in the mathematical programming language R, I just purchased an excellent, relatively new book, R for Dummies by Andrie de Vries and Joris Meys (Chichester, UK: John Wiley & Sons, 2012). Also, I decided to make a fresh installation of R and RStudio on my desktop. On this machine I run Linux Mint Maya (which is based on Ubuntu 12.04). The procedures I outline below should also work for Linux Mint Nadia and Ubuntu 12.10.
To begin, I installed R using the Synaptic Package Manager; depending on your system, this may involve searching in the SPM for "R", "r", or "r-base". Using the SPM is the simplest and easiest way I know of to get the basic components of R installed, using the version of R that is currently in the Ubuntu repositories.
Next, in order to use the latest updates to R, I added to the SPM a repository for such updates. To do this, I opened the Terminal and entered the following:
I gratefully acknowledge that I obtained the above command, and some others herein, from the following URL:
sudo add-apt-repository "deb http://cran.stat.ucla.edu/bin/linux/ubuntu precise/"
I used the University of California, Los Angeles mirror of the CRAN project because, having spent several semesters there as a graduate math student, I know that they have an active Department of Statistics, and, hence, I believe that they can be trusted to keep their CRAN mirror up-to-date. Also, this mirror is reasonably close to my location. If you want to locate a mirror closer to you, you can go to the following URL:
If you have selected a mirror that you would prefer to use, you should enter its identifying data in the
portion of the sudo add-apt-repository command shown above. If you are using Ubuntu 12.10, you would, of course, enter "quantal" in place of "precise".
"deb http://<your-preferred-mirror>/bin/linux/ubuntu precise/"
The LivesOnCoffee URL that I cited above recommends that for added security, you should "get the key and add it to your keyring (NOTE: the CRAN website says that some people are having issues with this step — if the commands here do not work for you, check there for latest information)". To obtain and add the key, enter these commands in the Terminal:
Next, to obtain and install the latest updates, enter these commands in the Terminal:
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -
The dependency checking that gdebi performs will ensure that the second line obtains the latest versions of the portions of R installed by the SPN.
sudo apt-get update
sudo apt-get install r-base
In using R, I like to take advantage of the convenience of using the GUI provided by RStudio. To add RStudio to your R installation, go to
and click on either "Download RStudio Desktop" or "Download RStudio Server". In the resulting page, choose the Debian version that corresponds to your machine (i.e., select the 32-bit or 64-bit version). Download the chosen version to your machine. Then, in the Terminal, use the "cd" command to move to the directory in which your downloads are saved, and issue this command:
If everything has worked as expected, you will be able to find RStudio listed among the programs available to you.
sudo gdebi <name of downloaded rstudio file ending in .deb>