Sunday, April 1, 2012

How to install R, JGR and Deducer in Ubuntu

A step-by-step guide about how to install the free statistical software GNU R, JGR and Deducer in Ubuntu (>= 10.04.4) and others Ubuntu derivative distributions. (see Romanian version / vezi versiunea în română)

The combination of GNU R, JGR and Deducer is a powerful free alternative to all proprietary / commercially distributed statistical programs like SPSS. Together, they provide a wide variety of statistical and graphical techniques, combined with intuitive graphical menus and dialogues that guide the user efficiently through the data manipulation and analysis process.

To install R, JGR and Deducer in Ubuntu, follow the steps described below, or use the installation script that I developed for this purpose.

1. Install the most recent R version

To obtain the latest R packages, add in your /etc/apt/sources.list file a repository URL for the Ubuntu archives on CRAN (choose a CRAN Mirror that is geographically close to you). Run in terminal:
sudo editor /etc/apt/sources.list

and add to the end of the file (replacing codename with your release code name; for example, mine release is called precise, from Precise Pangolin):
deb codename/

Add the secure key for the Ubuntu archives on CRAN (run in terminal):
gpg --keyserver --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -

Install R (run from terminal):
sudo apt-get update
sudo apt-get install r-base-dev

To avoid some later errors:
sudo apt-get install libx11-dev libglu1-mesa-dev libxml2-dev

If your network is behind a proxy/firewall, you can't directly install and update R packages. To solve the problem, you need to add to (one of) /etc/R/ or ~/.Rprofile files the following lines (substituting your own username, password, proxy server and port settings):

Note that the username:password@ part is needed only if the proxy requires authentication.

For me the added lines was:

Putting http_proxy= in ~/.Renviron will work too.

2. Install Java Development Kit and enable Java support in R

For this step follow instructions from the post How to install Java / OpenJDK in Ubuntu. Do not forget after that to enable Java support in R (run in terminal):
sudo R CMD javareconf

3. Install JGR, Deducer, DeducerExtras and DeducerRichOutput packages (for other extension packages for Deducer look in the online manual)

Run in terminal:
sudo R --no-save

Run in R environment:
update.packages(ask=FALSE, repos = '')
install.packages(c('JGR', 'Deducer', 'DeducerExtras'), repos = '')
install.packages('DeducerRichOutput', repos = '')
install.packages('XLConnect', repos = '') ## for importing Excel files

4. Add a menu entry for JGR

Run in R environment (started in previous step):

This will create a launcher for JGR.
Close (if) opened JGR window.

Download an icon image for JGR (run in terminal):
sudo wget -O /usr/share/icons/jgr-48x48.jpg

Create a .desktop file for the JGR menu entry. For this run in terminal:
sudo editor /usr/share/applications/jgr.desktop

and copy/paste the bellow content:
[Desktop Entry]
Name=JGR - Java Gui for R
Comment=Java Gui for R

Save created file with Ctrl+X.

5. Set JGR to auto-load Deducer, DeducerExtras and DeducerRichOutput packages

Start JGR from your account (Applications > Science > JGR - Java GUI for R), open Packages & Data > Package Manager menu, select load and default next to Deducer, DeducerExtras and DeducerRichOutput, click on Close button.

See Romanian version / vezi versiunea în română: Instalarea limbajului R în Ubuntu


Post a Comment