Thursday, 6 August 2015

Getting R/igraph installed

From a new linux-mint 17.2 install on my home computer:

R was missing, so I installed it using apt-get. The version that was installed by apt-get was 3.0.2, somewhat dated relative to the R-3.2.1 release that is currently available for download. So I deleted the apt-get installed version, and installed R-3.2.1. This required that x11 dev libraries and java7 dev kit were both available (they weren't to begin with). For completion, I wanted to create the R manuals and so had to install a few tex/latex things.

R
# The program 'R' is currently not installed. You can install it by typing:
# sudo apt-get install r-base-core

sudo apt-get install r-base-core 

Recommended packages:
sudo apt-get install r-recommended r-base-dev r-doc-html

Suggested packages:
sudo apt-get install ess r-doc-info r-doc-pdf r-mathlib \
    r-base-html tcl-tclreadline

R
# R is version 3.0.2


We remove R:
sudo apt-get remove r-base-core r-recommended r-base-dev \
    r-doc-html r-doc-info r-doc-pdf r-mathlib r-base-html

We download the latest version of R (R3.2.1) and install it
mkdir ~/Tools
cd ~/Tools
wget https://www.stats.bris.ac.uk/R/src/base/R-3/R-3.2.1.tar.gz
tar -xzvf R-3.2.1.tar.gz  
cd R-3.2.1/
./configure
# configure: error: --with-x=yes (default) and X11 headers/libs are not available

# installed x11 libraries
sudo apt-get install xorg-dev
./configure

# configure: WARNING: you cannot build info or HTML versions of the R manuals
# configure: WARNING: you cannot build PDF versions of the R manuals
# configure: WARNING: you cannot build PDF versions of vignettes and help pages

# installed texi2any etc
sudo apt-get install texinfo
./configure

# configure: WARNING: you cannot build PDF versions of the R manuals
# configure: WARNING: you cannot build PDF versions of vignettes and help pages

# install pdftex
sudo apt-get install texlive
./configure

# configure: WARNING: neither inconsolata.sty nor zi4.sty found: \
# PDF vignettes and package manuals will not be rendered optimally

# installed further texlive styles
# inconsolata and zi4 are present in texlive-fonts-extra
sudo apt-get install texlive-fonts-extra \
                     texlive-fonts-recommended

# install R
./configure
sudo make

# Failed:
# trying to compile and link a JNI program 
# detected JNI cpp flags    : 
# detected JNI linker flags : -L$(JAVA_HOME)/lib/i386/client -ljvm
# make[2]: Entering directory `/tmp/Rjavareconf.EIravR'
# gcc -std=gnu99 -I/home/russ/Tools/R-3.2.1/include -DNDEBUG  -I/usr/local/include    -fpic  -g -O2  -c conftest.c -o conftest.o
# conftest.c:1:17: fatal error: jni.h: No such file or directory
#  #include <jni.h>
                 ^
# compilation terminated.
# make[2]: *** [conftest.o] Error 1
# make[2]: Leaving directory `/tmp/Rjavareconf.EIravR'
# Unable to compile a JNI program


# JAVA_HOME        : /usr/lib/jvm/java-7-openjdk-i386/jre
# Java library path: 
# JNI cpp flags    : 
# JNI linker flags : 
# Updating Java configuration in /home/russ/Tools/R-3.2.1
# Done.

# installed java7 dev kit:
sudo apt-get install openjdk-7-jdk
./configure
sudo make

make check
make pdf
make info

sudo make install
sudo make install-info
sudo make install-pdf

# in a new terminal tab:
R
> install.packages('igraph')
Warning in install.packages("igraph") :
  'lib = "/usr/local/lib/R/library"' is not writable
Would you like to use a personal library instead?  (y/n) y

Would you like to create a personal library
~/R/i686-pc-linux-gnu-library/3.2
to install packages into?  (y/n) y

# use http version of UK::Bristol
library(igraph)


1 comment:

  1. Hello, I am also just installing R.
    How was your experience with R?))

    ReplyDelete