22
Apr

SPSS Alternative for Linux [Ubuntu Tutorial]

This guide is intended to help users install and configure “R”, a great, free alternative to SPSS.  The instructions that I outline here are tailored to Ubuntu 8.04 (Hardy Heron), but can be alternated to fit any Linux distribution.

What is “R”?

This is right from the R homepage:

R is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&T, now Lucent Technologies) by John Chambers and colleagues. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.

R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.

What is JGR?

Unfortunately, R is based on CLI.  This is where JGR comes into play.  JGR is a GUI interface for the R program. This is from the JGR homepage:

JGR (speak ‘Jaguar’) is a universal and unified Graphical User Interface for R (it actually abbreviates Java Gui for R). JGR was introduced at the useR! meeting in 2004 and there is an introductory article in the Statistical Computing and Graphics Newsletter Vol 16 nr 2 p9-12

Installation:

We begin by simply installing R, Java, and all dependencies in one command:
[In Terminal] sudo apt-get install -y r-base-dev r-recommended sun-java6-jdk

When everything is finished downloading and is about to install, you will be prompted to accept the EULA from Sun Java:
screenshot-debconf-on-vaio.png

Check the “Do you agree with the DLJ license terms?” and hit “Forward”. Allow the installer to finish before continuing.

Enable support for Java in R:
[In Terminal] sudo update-java-alternatives -s java-6-sun
[In Terminal] sudo R CMD javareconf

Now, installing JGR:
[In Terminal] sudo R
[In R] install.packages('JGR')
After entering the above command, a prompt to select the closest mirror will appear:

screenshot-cran-mirror.png

Select the closest mirror to you and continue by running this command within R:
[In R] library(JGR)

Running it:

Run JGR from inside R:
[In R] JGR()

Run JGR from the terminal:

[In Terminal] /usr/local/lib/R/site-library/JGR/scripts/run

You should then be pleasantly greeted with the JGR interface:
screenshot-console.png

Thank you for using my tutorial. If you thought this was useful, you may want to consider subscribing to my Linux RSS Feed to get updates for more Linux tips and tricks. Don’t forget to comment as well!

Basic Troubleshooting:

This section will be expanded upon as I recieve input from the comments below.

If you get an error message while trying to load the JGR library (or at the end of the “install.packages(‘JGR’) command that looks like, or contains the following:
“installation of package ‘maps’ had non-zero exit status”
“installation of package ‘CarbonEL’ had non-zero exit status”
“installation of package ‘rJava’ had non-zero exit status”
“installation of package ‘JavaGD’ had non-zero exit status”
“installation of package ‘mapproj’ had non-zero exit status”
“installation of package ‘iplots’ had non-zero exit status in”

Then you will need to make sure that (1) you in fact have the package sun-java6-jdk installed, and (2) you have also run the two commands in the “Enable Java in R” section of this tutorial.

Sources: JGR Installation Guide for Feisty

Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:


There's 3 Comments So Far

  • Nataraj
    October 15th, 2009 at 10:54 am

    This post was extremely useful. Highly appreciated.
    Thanks

  • mozzribo
    March 26th, 2014 at 7:10 pm

    Outdated (I guess), doesn’t work. :T

    Here’s what I did:

    1. after:
    ——————————————————————————
    sudo apt-get install -y r-base-dev r-recommended sun-java6-jdk
    ——————————————————————————
    I get:
    ——————————————————————————
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Package sun-java6-jdk is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    E: Package ‘sun-java6-jdk’ has no installation candidate
    ——————————————————————————

    2. I have java 7, so I tried:
    ——————————————————————————
    sudo apt-get install -y r-base-dev r-recommended sun-java7-jdk
    ——————————————————————————
    and got:
    ——————————————————————————
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package sun-java7-jdk
    ——————————————————————————

    3. then:
    ——————————————————————————
    sudo update-java-alternatives -s java-6-sun
    ——————————————————————————
    get:
    ——————————————————————————
    update-java-alternatives: directory does not exist: /usr/lib/jvm/java-6-sun
    ——————————————————————————

    4. then:
    ——————————————————————————
    sudo R CMD javareconf
    ——————————————————————————
    get:
    ——————————————————————————
    Java interpreter : /usr/bin/java
    Java version : 1.7.0_51
    Java home path : /usr/lib/jvm/java-7-openjdk-i386/jre
    Java compiler : not present
    Java headers gen.:
    Java archive tool:

    trying to compile and link a JNI progam
    detected JNI cpp flags :
    detected JNI linker flags : -L$(JAVA_HOME)/lib/i386/client -ljvm
    gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -O3 -pipe -g -c conftest.c -o conftest.o
    conftest.c:1:17: fatal error: jni.h: No such file or directory
    #include
    ^
    compilation terminated.
    make: *** [conftest.o] Error 1
    Unable to compile a JNI program

    Java library path:
    JNI cpp flags :
    JNI linker flags :
    Updating Java configuration in /usr/lib/R
    Done.
    ——————————————————————————

    5.: sudo R gets me into R
    ——————————————————————————

    6.:
    ——————————————————————————
    install.packages(‘JGR’)
    ——————————————————————————
    ends with:
    ——————————————————————————
    Warning messages:
    1: In install.packages(“JGR”) :
    installation of package ‘rJava’ had non-zero exit status
    2: In install.packages(“JGR”) :
    installation of package ‘JavaGD’ had non-zero exit status
    3: In install.packages(“JGR”) :
    installation of package ‘iplots’ had non-zero exit status
    4: In install.packages(“JGR”) :
    installation of package ‘JGR’ had non-zero exit status
    ——————————————————————————

    7.
    ——————————————————————————
    library(JGR)
    ——————————————————————————
    gives:
    ——————————————————————————
    Error in library(JGR) : there is no package called ‘JGR’
    ——————————————————————————

    8.:
    ——————————————————————————
    JGR()
    ——————————————————————————
    get:
    ——————————————————————————
    could not find function “JGR”
    ——————————————————————————

    The rest doesn’t work… I installed java 6 and 7 JDK in SManager.

    Ran terminal with root privileges.

    Using Linux Mint 16 Cinnamon Petra

    What am I doing wrong? Please help, if You can. 🙂

    Or at least explain how to revert changes made by this, if it’s a lost case.

    https://cdn.meme.li/i/kgebn.jpg

  • SPSS
    July 1st, 2016 at 6:33 pm

    This guide is very Ubuntu-centric. I’m afraid I don’t have much experience with other distrubtions, but hopefully these can be adapted somewhat for your platform.

Share your thoughts, leave a comment!