R

Program description:

R is a language and environment for statistical computing and graphics. R is similar to the award-winning S system, which was developed at Bell Laboratories by John Chambers et al. It provides a wide variety of statistical and graphical techniques (linear and nonlinear modelling, statistical tests, time series analysis, classification, clustering, ...).

Versions:

Name: R
Version: 3.1.2
Platform: x86_64
Category: Applications/Engineering
URL: http://www.r-project.org
Provides: R

Example of a start-up script SLURM:

#!/bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --mem=4gb
#SBATCH --time=01:00:00

# Ustawiamy sciezki lub ladujemy odpowiednie moduly
module load r

# Ustawiamy zmienna $TMPDIR
export TMPDIR="/tmp/lustre_shared/${USER}/${SLURM_JOBID}"

# Ustawiamy zmienne aplikacji
export SCR=${TMPDIR}

# Ustawiamy zmienne pomocnicze
INPUT_DIR="input"
OUTPUT_DIR="output"
OUTPUT_FILE="OUTPUT"

# Tworzymy katalog tymczasowy
mkdir -p ${TMPDIR}

# Kopiujemy dane wejsciowe do katalogu wskazywanego zmienna $TMPDIR
cp ${SLURM_SUBMIT_DIR}/${INPUT_DIR}/* ${TMPDIR}

# Przechodzimy do katalogu $TMPDIR
cd $TMPDIR

# Naglowek

cat << EOF
-------------------------------------------------------------------------------

Start of calculations [$(date)]
EOF

echo -n 'Job is running on node: ';awk '!x[$0]++' $PBS_NODEFILE | tr '\n' ' '
echo -e '\n'

cat << EOF
-------------------------------------------------------------------------------
Support:        support-hpc@man.poznan.pl
-------------------------------------------------------------------------------
EOF

# Wykonujemy obliczenia
R --no-save < Rtest.r

# Stopka
cat << EOF
-------------------------------------------------------------------------------

End of calculations [$(date)].

-------------------------------------------------------------------------------
EOF

# Konczymy obliczenia, zawartosc katalogu $TMPDIR/output kopiujemy 
# do katalogu z ktorego zakolejkowano zadanie.
mkdir $SLURM_SUBMIT_DIR/${OUTPUT_DIR}
cp -r $TMPDIR/* $SLURM_SUBMIT_DIR/${OUTPUT_DIR}/

# Czyscimy katalog roboczy
rm -rf $TMPDIR

Sample input data: Below are the files that should be in the input directory.
Plik:r_input.zip

RStudio graphic interface

To start the GUI, open https://rstudio.man.poznan.pl/ and log in with the user name and password used to log in to the system eagle.man.poznan.pl

Rstudio log.png


After logging in you will receive a graphic panel of the RStudio software

Rstudio panel.png

Examples of calculations

> x <- c(1, 2, 3, 4, 5, 6)
> y <- x^2 
> print(y)

result

[1]  1  4  9 16 25 36
Rstudio wynik.png

Installation of packages in the RStudio graphical interface


In the view we turn on Show Packages

R1.jpg


Then in the Packages tab, click Install

R2.jpg


Choose the package you want to install from the repository, for example, the modeest package has been installed, and then run the installation Install

R3.jpg


The package has been installed, in the Packages tab in the User Library category, select the package to load it into the system

R4.jpg


The moddees pack has been activated

R5.jpg


To test the operation of the package we can do the following

R6.jpg

Installation of R-packages in interactive mode


We start the interactive mode

srun -p fast --pty /bin/bash


We load the R-module

module load r
gmp/5.1.3 load complete.
mpfr/3.1.2 load complete.
libmpc/1.0.1 load complete.
gcc/6.2.0 load complete.
openmpi/4.0.0_gcc620 load complete.
r/3.5.1-gcc620 load complete.


We start the R

~$ R


We install a package, for example a modeest package

install.packages('modeest')


We will be asked to select the source of the package, select 1

Selection: 1
trying URL 'https://cloud.r-project.org/src/contrib/modeest_2.4.0.tar.gz'
Content type 'application/x-gzip' length 34996 bytes (34 KB)
==================================================
downloaded 34 KB

* installing *source* package ‘modeest’ ...
** package ‘modeest’ successfully unpacked and MD5 sums checked
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (modeest)

The downloaded source packages are in
        ‘/tmp/RtmpPFM8j0/downloaded_packages’


The package has been installed

We load the installed package into the system

> library('modeest')


We run a sample task using the installed package

> x <- c(1,2,3,4,4,5)
> mfv(x)

[1] 4