Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

Eine weit verbreitete Programmierumgebung für statistische Berechnungen und Grafiken.

Inhalt
typeflat

Versionen

Aktuell haben wir auf dem Cluster Version 4.2.2 als neueste Version von R installiert. Aus Gründen der Kompatibilität werden jedoch auch ältere Versionen (siehe rechte Spalte) angeboten.

Alle Versionen wurden mit dem Intel Compiler aus dem Intel® Parallel Studio XE übersetzt und sind gegen die Intel MKL gelinkt.

Info
titleLatest Information

Currently we have a mirror for CRAN to allow you to install packages without direct internet access. Please use http://cran.repo.test.hhu.de/ as mirror on Hilbert.

We have also installed a Mirror mirror for Bioconductor, use 

Codeblock
options(BioC_mirror = "http://bioc.repo.test.hhu.de")

in R to access the local mirror (working with R Versions 4.0.3 and 4.2.2).



Zusatzpakete

Eine Liste aller Zusatzpakete innerhalb von R erhält man mit:

Codeblock
languagecpp
themeEclipse
titleListe aller Pakete in R
ip <- as.data.frame(installed.packages()[,c(1,3:4)])
rownames(ip) <- NULL
ip <- ip[is.na(ip$Priority),1:2,drop=FALSE]
print(ip, row.names=FALSE)


In der aktuellen Version sind folgende Zusatzpakete vorhanden (Stand 14.05.2019):


PaketVersion
assertthat0.2.1
BH1.69.0-1
bigmemory4.5.33
bigmemory.sri0.1.3
bit1.1-14
cli1.1.0
coda0.19-2
colorspace1.4-1
crayon1.3.4
deSolve1.21
doParallel1.0.14
foreach1.4.4
glue1.3.1
iterators1.0.10
lazyeval0.2.2
magrittr15
plyr1.8.4
Rcpp1.0.1
reshape0.8.8
reshape21.4.3
stringi1.4.3
stringr1.4.0
SuppDists1.1-9.4
whisker0.3-2


Eigene Pakete hinzufügen

R ermöglicht es, eigene bzw. zusätzliche Pakete in das Home-Verzeichnis zu installieren. Dazu muss zunächst von CRAN das gewünschte Source-Paket (im tar.gz-Format) herunterladen werden. Danach kann dies, z. B. in einem interaktiven Job, wie folgt installiert werden:

  1. R-Modul laden

    Codeblock
    languagebash
    module load R/3.6.1


  2. Verzeichnis(se) für weitere Pakete anlegen (falls noch nicht geschehen)

    Codeblock
    languagebash
    mkdir -p ~/R/libs


  3. diesen neuen Pfad für R bekannt machen

    Codeblock
    languagebash
    echo 'R_LIBS_USER="~/R/libs"' >> $HOME/.Renviron


  4. neues Paket (als Beispiel mypackage.tar.gz) in diesen Pfad installieren

    Codeblock
    languagebash
    R CMD INSTALL -l ~/R/libs/ mypackage.tar.gz


Sollen weitere Pakete installiert werden, dann erübrigen sich die ersten Schritte (insbesondere 2. und 3.).


Info
titleTipp für andere Archiv-Formate

R scheint an dieser Stelle nur tar.gz-Archive zu verstehen. Leider bieten manche Download-Seiten aber nur andere Archiv-Formate, wie bspw. ZIP, zum Herunterladen an. Falls dies der Fall sein sollte, kann man mittels

unzip mypackage.zip
das heruntergeladene Archiv entpacken und dann mittels
tar --create --verbose --gzip --file=mypackage.tar.gz mypackage/
wieder in ein tar.gz-Archiv packen. Damit sollte dann der 4. Schritt funktionieren.


Info
titleBeispielinstallation mittels CRAN
$ mkdir -p ~/R/libs
$ module load R/4.0.3
$ R
> install.packages("tidyselect", lib = "~/R/libs/", repos = "http://cran.repo.test.hhu.de/")
...
* DONE (tidyselect)

Parallel Execution

It is possible in R to execute methods in parallel across multiple cores with the library 'parallel': https://dept.stat.lsa.umich.edu/~jerrick/courses/stat701/notes/parallel.html. The method detectCores() returns incorrect numbers and should not be used. A good replacement is https://github.com/HenrikBengtsson/parallelly.  To the best of our knowledge other commonly used R libraries for parallel Execution as 'doParallel', 'doSNOW' or 'foreach' are only addressing one core.

A second possibility is - if possible - seperating your job in the RScript into several tasks (below 200 tasks from 0 to 199).

Codeblock
languagebash
firstline1
titleYourShellScript.sh
linenumberstrue
#!/bin/bash
#PBS -A YourProject
#PBS -l select=1:ncpus=1:mem=8G
#PBS -l walltime=01:59:00
#PBS -r y
#PBS -J 0-199

module load R/4.0.3

jobargs=$(echo "'--args ${PBS_ARRAY_INDEX}'")
jobstr=$(echo "R CMD BATCH --no-save --no-restore ${jobargs} your_script.R your_script.Rout")
eval ${jobstr}

The job argument (0 to 199 in this example) can be used in your RScript as followed:

Codeblock
titleyour_script.R
args = commandArgs(TRUE)
...

Of course both ways to parallel processing using R can be combined by creating several jobs which use multiple cores with the library 'parallel'.

Common Errors

error #308: member "std::complex::_M_value" (declared at line 1337 of "/usr/include/c++/4.8.5/complex") is inaccessible

The Intel compiler, that we use to build R, conflicts with gcc headers when using complex data types, resulting in an error similar to the one below when installing some R libraries:

Codeblock
/software/intel/xe2019/compilers_and_libraries_2019.0.117/linux/compiler/include/complex(310): error #308: member "std::complex<double>::_M_value" (declared at line 1337 of "/usr/include/c++/4.8.5/complex") is inaccessible

The workaround this is to disable this diagnostic error by creating (or modifying) file ~/.R/Makevars such as:
Codeblock
languagebash
title~/.R/Makevars
 CFLAGS += -wd308
CXXFLAGS += -wd308
CPPFLAGS += -wd308
PKG_CFLAGS += -wd308
PKG_CXXFLAGS += -wd308
PKG_CPPFLAGS += -wd308


Inhalt

verfügbare Versionen
3.0.2
3.2.3
3.3.2

3.5.3

3.6.1

4.0.3

4.2.2