R for Beginners: Installing the latest version of R on a Linux platform
A tutorial by D. M. Wiig
One of the nice characteristics of open source software such as R is the rapid development of new releases and updates. While the base core remains stable for a period of time there is a considerable amount of updating, adding, and removing the component packages. At the time of this writing the latest iteration is R version 3.3.1, “Bug in Your Hair.” If you are using a Windows platform you will likely go directly to the archive web site and download the latest distribution as a Windows executable installation package.
If you are using a Linux distribution such as Ubuntu or Debian, the process of adding software is usually accomplished via the menu based installer. These software installers allow R and its dependencies to be downloaded from the community archive.
One of the disadvantages of using this approach is that the versions of some software in the archives may not be updated to the latest version. This is often the case with R.
To insure that you are downloading the latest R version you need to use the platform’s command line to install what is needed. Regradless of which Linux distribution you are using first open a command console from the desktop menu. Make sure all is up to date by using the command:
[email protected]:~ $ sudo apt-get update
This will insure all appropriate packages currently installed are running the latest updates. If you are running a Debian distribution such as jessie you will need to edit the /etc/apt/sources.list file to add a backport to the latest version of R. Use the nano editor by using the command:
sudo nano /etc/apt/sources.list
This should produce the output as seen below:
[email protected]pberrypi:~ $ sudo nano /etc/apt/sources.list ------------------------------------------------ GNU nano 2.2.6 File: /etc/apt/sources.list deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free r$ # Uncomment line below then 'apt-get update' to enable 'apt-get source' deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi deb http://archive.raspbian.org/raspbian/ stretch main deb http://mirror.las.iastate.edu/CRAN/bin/linux/debian/ jessie main deb http://mirror.las.iastate.edu/CRAN/bin/linux/ubuntu xenial/
[ Read 8 lines ]
^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos
^X Exit ^J Justify ^W Where Is ^V Next Page ^U UnCut Text^T To Spell
If you are using a Debian distribution you would add the line to the file
http://mirror.las.iastate.edu/CRAN/bin/linux/debian/ jessie main Replace the mirror portion with
. Replace the 'jessie' portion with the name of the specific Debian distribution you are using. If you are using an Ubuntu distribution add a line with the appropriate changes for the specific Ubuntu distribution that you are using. Once these changes are made exit the nano editor using the ^O key command to write the file and then the ^X key command to return to the command line. You should now be able to issue the command: [email protected]:~ $ sudo apt-get install r-base r-base-core r-base-dev Once the download and install processes have completed you should now be able to invoke R from the command line or menu and see the latest version: [email protected]:~ $ R R version 3.3.2 RC (2016-10-23 r71578) -- "Sincere Pumpkin Patch" Copyright (C) 2016 The R Foundation for Statistical Computing Platform: arm-unknown-linux-gnueabihf (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > For other Linux distributions you would add a line similar to the above examples in the /etc/apt/sources.list. Check the documentation for your specific Linux platform for further information.