Installation GNU R

From SONIVIS:Wiki

Jump to: navigation, search

Preliminaries: GNU R

  • Download and install R: http://cran.r-project.org/mirrors.html
    • Linux: Use the source tarball, if you encounter any problems with R. R must be compiled using --enable-R-shlib as configuration option, which some distros do not do.
      • The directory containing libR.so and the directory containg jri.so must be in the environment variable LD_LIBRARY_PATH.
      • Also libjvm.so and other dependent Java libraries must be on LD_LIBRARY_PATH.
      • You may have to run sudo R CMD javareconf before installing R-packages.

Installation on different distributions:

  • Gentoo: in portage is still Version 2.6.1 please do not use emerge instead build R from source
    1. tested with R-2.6.2 from source
  • Debian (2.7.x binary version) (untested) :
    1. add deb http://<favorite-cran-mirror>/bin/linux/debian etch-cran/ to your sources.list
    2. apt-get update
    3. apt-get install r-base
  • Ubuntu (2.7.x binary version):
    1. add deb http://<my.favorite.cran.mirror>/bin/linux/ubuntu {distro}/ to your sources.list with {distro} = dapper or feisty or gutsy or hardy
    2. sudo apt-get update (Recommendation: Execute this on your shell instead of using a graphical package manager since this will probably not give you appropriate error info. If apt-get gives you a warning on a missing key by the cran mirror first apply the steps in section SECURE APT at http://ftp5.gwdg.de/pub/misc/cran/bin/linux/ubuntu/. After having imported the key anything should work out fine.)
    3. sudo apt-get install r-base r-base-dev libmysqlclient15-dev libxml2-dev
  • Debian/Ubuntu (source tarball):
    1. Download the source version from http://ftp5.gwdg.de/pub/misc/cran/
    2. tar xzvf R-2.7.x.tar.gz
    3. cd R-2.7.x
    4. ./configure --enable-R-shlib
    5. make && sudo make install
  • SuSE:
  • Windows: Download binary from mirror and execute
  • Mac OS X (>10.4): Installation under Mac OS is pretty straight forward. Just download the binaries from the GNU R project homepage and install the basic system. The packages you'll need install fine if you follow the Linux guidelines above. The only package that might turn out to be problematic is "RStem" which is not available through the CRAN mirrors and fails to download from the RStem Homepage through the R Package Manager. Here's a workaround to install it anyway:
    1. As a prerequisite you'll need a recent version of GCC and make. The easiest way to obtain both might be installing XCode from the Apple Developers Connection (you'll need to sign up there). This enables you to handle makefiles and gets you a new GCC.
    2. Download the newest stable release of the RStem package from the project homepage: http://www.omegahat.org/Rstem/
    3. After unpacking the downloaded archive you'll need to install the package with administrative privileges from the unpacked directory. The easiest way to do this is using the GUI of R which you need to start as a super user (sudo from the terminal). You can use the package manager to install the manually downloaded package by switching from the CRAN mirrors to "Local package (from a directory)" in the source dropdown of the package manager.
    4. Choose your RStem directory and watch it being installed in your R console.
    5. Afterwards you're all set.

After Installation on your favorite OS:

  • Run (sudo) R and type (DO AS ROOT!!!):
    • before installing packages on linux remind to run sudo R CMD javareconf
    • install.packages("rJava")
      • Ubuntu: On problems related to your Java Installation check the following:
        1. You have a Java Runtime Environment (JRE) Version 6 installed
        2. You have a Java Development Kit (JDK) Version 6 installed
        3. Your system uses this Java 6 by default. sudo update-java-alternatives --list. The listing should show a java-6... (i.e., java-6-sun) installation as first. If not so move it up in the list with sudo update-java-alternatives --set java-6-sun.
        4. Run sudo R CMD javareconf. All of the fields displaying the Java configuration should contain data.
    • install.packages("sna")
    • install.packages("igraph")
      • Known bug related to igraph installation in Debian Lenny (testing), with GNU gcc 4.3. You should wait to use igraph_0.5.1.tar.gz or above from the main repositories, or else, get it from [1]
    • install.packages("pls")
    • install.packages("RMySQL") (to install from local *.zip-file please also install denpendent packages manually)
      • dependencies DBI
      • Windows: extract LibMySQL.zip and add the dll-File to <R_HOME>/library/RMySQL/libs or add the directory of another LibMySQL.dll file to the PATH environment variable
      • Ubuntu: the file mysql.h is required. Ensure you have the MySQL database development package libmysqlclient15-dev (or later) installed.
    • install.packages("Rstem", repos = "http://www.omegahat.org/R")
    • install.packages("tm") (to install from local *.zip-file please also install denpendent packages manually)
      • dependencies RWeka, filehash, Matrix, Snowball, XML, proxy
      • in case R isn't able to resolve some internal dependencies to other packages (tm,i.e., requires package Snowball which in turn requires package RWeka) install mentioned package directly. install.packages("RWeka") is a good start
      • Ubuntu: if required R package XML isn't installable, make sure you have Ubuntu package libxml2-dev installed. It contains the required file xml2-config.
  • R_HOME must be set correctly (C:\Program Files\R\R-2.7.0 respectively /usr/local/lib/R)
under Windows Vista: as system variable in environment variables

For Linux, see also /usr/local/lib/R/jri/run for an example!

  • fast method to set up right $PATH and $R_HOME use the scripts

Help in GNU R

  • search for a special phase in all packages (+ descriptiopn), use help.search("<phase>")
    • Example: help.search("network")
  • search for help on a special method/function, use ?<method>
    • Example: ?plot same as help("plot")
  • complete list of functions, use ls(package:<packagename>)
    • Example: ls(package:network)
  • obtain the description and a list of functions, use help(package="<packagename>")
    • Example: help(package="network")

NOTE: for displaying functions, list of functions or a description of a package you have to load the packages first with library(<packagename>)

Personal tools