Installing R and JGR in Ubuntu Intrepid
Here’s an update to my previous instructions on getting R set up and working in Ubuntu. These work for Ubuntu Intrepid, but won’t work for Ubuntu Jaunty (due out next month) until you see “jaunty” in this list.
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. I recommend using the RSeek search engine to search for help and 3rd party libraries.
To install R, open the Terminal console and run these commands:
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 intrepid/
Note the trailing slash at the end of “intrepid/”. Also 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:
sudo apt-get install r-base r-base-dev r-recommended
Then run “R” to start R, and “q()” to quit it.
To get JGR, the Java GUI interface working (requires you have java installed, see the sun-java6 package), run this on the command line:
sudo R CMD javareconf
Then run “R” and re-install the JavaGD package (because of a bug). Inside R run:
install.packages(“JavaGD”)
Assuming that succeeds, install JGR now too:
install.packages(“JGR”)
All this should be installing under your home folder:
/home/(yourname)/R/i486-pc-linux-gnu-library/2.8/
You can run JGR now with these commands:
library(JGR)
JGR()
In the future, you can run JGR with a single click by going to the folder where the JGR run script was created and dragging that script to your top Ubuntu panel bar:
/home/(yourname)/R/i486-pc-linux-gnu-library/2.8/JGR/scripts/run
Good luck!
Getting R Set Up in Ubuntu
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):
R
To quit R, type this command inside R:
q()
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.
Installing JGR
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:
/usr/lib/jvm/java-6-sun
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:
install.packages("JGR",dep=TRUE)
Now anytime you want to run JGR, type these commands in R:
library(JGR) JGR()
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:
install.packages("Rcmdr", dependencies=TRUE)
And to run R Commander, type this in R:
library(Rcmdr) //or run this if you quit R Commander in session already: Commander()
Installing RKWard
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:
update.packages()
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.
