UPDATE: See these instructions for installing R in Ubuntu Intrepid. The instructions are mostly the same, except if you want to use JGR, you have to re-install JavaGD first.
R is a free, open source software package for performing statistical analyses. It is an alternative to commercial tools such as SPSS, SAS, and S. Here is a walkthrough on installing the latest version of R in Ubuntu Linux (Feisty), along with some graphical front-ends (JGR and R Commander and RKWard) and an R extension for OpenOffice. For instructions on installing these tools in Windows and Mac OS X, please see their respective websites.
In Ubuntu, this requires typing some commands in the Terminal (in the menu under Applications->Accessories). It seems like a lot of work, but most of the work you only have to do once, and it should be even easier in the future (when Ubuntu Gutsy is released). The version of R available in the Ubuntu Feisty repository is 2.4, however, the latest version of R at the moment is actually 2.5. If you are fine using 2.4, go to the System menu -> Administration -> Synaptic Package Manager and
search for “r-base” to install R that way. Otherwise, here are a few extra steps required to have access to the latest version (2.5):
Installing the Latest Version of R in Ubuntu
I am basing my instructions on this readme, which is unfortunately written out of order and incomplete. First in the terminal type these lines to add the security key to access the latest version of the R Ubuntu package:
gpg --keyserver subkeys.pgp.net --recv-key E2A11821 gpg -a --export E2A11821 | sudo apt-key add -
Then open up your apt-get sources list for editing:
sudo gedit /etc/apt/sources.list
Add this line to the bottom of the sources.list file:
deb http://rh-mirror.linux.iastate.edu/CRAN/bin/linux/ubuntu feisty/
You can replace “rh-mirror.linux.iastate.edu” with another mirror server of your choice. Save the file and go back to the Terminal.
Now type this in the terminal to update apt-get’s database before you install R:
sudo apt-get update
Install R with this command (the r-base-dev package is optional):
sudo apt-get install r-base r-base-dev
How to Start and Stop R
To start R, type “R” in the Terminal command line (no quotes, and uppercase):
To quit R, type this command inside R:
And say yes to save the session if you wish.
Inside R, you can install either one of 2 GUI front ends to R, JGR and R Commander.
To install JGR, first quit R. You need to make sure you have java installed and configured for use with R first.
To install Java 6 from Sun in Ubuntu, search for “java6″ in the Synaptic Package Manager and install the Java 6 packages. Then run this command in the terminal to configure Ubuntu to use Java 6 (this should not be required in Ubuntu Gutsy):
sudo update-alternatives --config java
Open /etc/jvm to set the default java runtime to use:
sudo gedit /etc/jvm
And add this line to the TOP of the file:
Then once java is properly configured, we can configure R to use Java. Type this command:
sudo R CMD javareconf
Now run R and type these lines in R to install JGR:
Now anytime you want to run JGR, type these commands in R:
Be sure when you exit R to save the session, so that you do not have to install JGR again.
Installing R Commander
To install R Commander, type this command inside R:
And to run R Commander, type this in R:
library(Rcmdr) //or run this if you quit R Commander in session already: Commander()
To install RKWard, version 0.4.2 is available in the Ubuntu repositories, or else you can compile the newest version (0.4.7) manually yourself or else install the debian package on their site. See the site and the install notes contained in the download.
Updating Packages in R
Anytime you want to update the packages installed in R, type this command:
If you get errors compiling, you may need to install the build-essential package (using the synaptic package manager). If you get permission errors, you may need to quit R (type “q()”), the start R again with root permissions (“sudo R”). Then run update.packages() again and it should work.
Installing an R Extension for OpenOffice
There is also an R Extension for the OpenOffice spreadsheet tool (Calc) which may be worth trying. See the instructions on their site for installing. It requires installing the RServe package in R first, along with OpenOffice and Java. One missing item in the instructions is that the unopkg command line tool is located at /usr/lib/openoffice/program/unopkg
Learning more about R
It looks like a lot of hassle, but in the end you get a free, open source environment that is as powerful as SPSS/SAS and runs on any platform. There is a wealth of documentation out there on R, including numerous books on Amazon:
- Numerous free 3rd party tutorials and courses on R
- Introductory Statistics with R – book by Peter Dalgaard
- Data Analysis and Graphics Using R: An Example-based Approach- book by John Maindonald
- And there are at least 2 or 3 other books on Amazon about R as well.