BwUniCluster2.0/Software/R: Difference between revisions
M Dynowski (talk | contribs) No edit summary |
|||
(92 intermediate revisions by 11 users not shown) | |||
Line 1: | Line 1: | ||
{{Softwarepage|math/R}} |
|||
<!--{| align="right" {{Table|width=40%}} --> |
|||
{|{{Softwarebox}} |
|||
{| width=600px class="wikitable" |
|||
|- |
|- |
||
! Description !! Content |
|||
! colspan="2" style="text-align:center" | R |
|||
|- |
|- |
||
| module load |
| module load |
||
| math/R |
| math/R |
||
<!-- Neben CIS auch bereits über Kategorien abgedeckt--> |
|||
|- |
|||
| Availability |
|||
| [[bwUniCluster]] |
|||
<!-- |
|||
[[bwForCluster ENM]], [[bwForCluster MLS/WISO]], [[bwForCluster Theochem]], [[bwForCluster BinAC]] |
|||
--> |
|||
|- |
|- |
||
| License |
| License |
||
| GPL |
| GPL |
||
|- |
|- |
||
|Citing |
| Citing |
||
| n/a |
|||
|- |
|- |
||
| Links |
| Links |
||
| [http://www.r-project.org/ Homepage]; [http://cran.r-project.org/manuals.html Documentation] |
| [http://www.r-project.org/ Homepage] | [http://cran.r-project.org/manuals.html Documentation] |
||
| |
|||
|- |
|- |
||
| Graphical Interface |
| Graphical Interface |
||
| No |
|||
| No <!-- Yes could link to some x11-forwarding/vnc instructions --> |
|||
|- |
|- |
||
| Plugins |
|||
| Included in module |
|||
| User dependent |
|||
| <!-- mention if there is more than one software in the module, i.e. icc, ifort and debugger --> |
|||
|} |
|} |
||
= Description = |
|||
== Description == |
|||
'''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''' 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. |
||
Line 41: | Line 34: | ||
R is available as Free Software under the terms of the Free Software Foundation’s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and MacOS. |
R is available as Free Software under the terms of the Free Software Foundation’s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and MacOS. |
||
= Usage = |
|||
The R installation also provides the standalone library libRmath. This library allows you to access R routines from your own C or C++ programs (see section 9 of the 'R Installation and Administration' manual). |
|||
== Installing R-Packages into your home folder == |
|||
== Versions and Availability == |
|||
Since we cannot provide a software module for every R package, we recommend to install special R packages locally into your home folder. One possibility doing this is from within an interactive R session: |
|||
A current list of the versions available on the bwUniCluster and bwForClusters can be obtained from the Cluster Information System: [http://cis-hpc.uni-konstanz.de/prod.cis/math/R CIS Information on R] |
|||
On the command line interface of any bwHPC cluster, a list of the available R versions using |
|||
<pre> |
<pre> |
||
> library() # List preinstalled packages |
|||
$ module avail math/R |
|||
> install.packages('package_name', repos="http://cran.r-project.org") # Installing your R package and the dependencies |
|||
> library(package_name) # Loading the package into you R instance |
|||
</pre> |
</pre> |
||
The package is now installed permanently in your home folder and is available every time you start R. |
|||
'''Note:''' |
|||
== Usage == |
|||
By default R uses a version (and platform) specific path for personal libraries, such as |
|||
The R installation also provides the standalone library libRmath. This library allows you to access R routines from your own C or C++ programs (see section 9 of the 'R Installation and Administration' manual.) |
|||
"$HOME/R/x86_64-pc-linux-gnu-library/x.y" for R version x.y.z. This directory will be created automatically (after confirmation) when installing a personal package for the first time. |
|||
Users can customize a common location of their personal library packages, e.g. ~/R_libs, rather than the default location. A customized directory must exist before installing a personal package for the first time, i.e. |
|||
=== Loading the module === |
|||
You can load the default version of R with the command |
|||
<pre> |
<pre> |
||
$ mkdir -p ~/R_libs |
|||
$ module load math/R |
|||
</pre> |
</pre> |
||
The location must also be defined in a configuration file ~/.Renviron within the home directory containing the following line: |
|||
The module will try to load modules it needs to function (e.g. compiler/intel). If loading the module fails, check if you have already loaded one of those modules, but not in the version needed for R. |
|||
If you wish to load a specific (older) version, you can do so using e.g. |
|||
<pre> |
<pre> |
||
R_LIBS_USER="~/R_libs" |
|||
$ module load math/R/3.1.2 |
|||
</pre> |
</pre> |
||
to load the version 3.1.2. |
|||
By setting up a (fixed) custom location for personal library packages, any personal package installed into that directory will be visible across different R versions. This may be advantageous if the packages are to be used with different (future) R versions. |
|||
A version specific path, such as the default path, allows users to maintain multiple personal library stacks for different (major and minor) R versions and does also prevent users from mixing their stack with libraries built with different R versions. |
|||
=== Program Binaries === |
|||
The drawback is that, whenever switching to a new R release, the personal library stack '''must''' be rebuilt with that new R version into the corresponding (version specific) library path. This is considered good practice anyway in order to ensure a consistent personal library stack for any specific R version in use. Mixing libraries built with different major and minor R versions is discouraged, as this may (or may not) result in unpredictable and subtle errors. Packages that are built and installed with one version of R may be incompatible with a newer version of R, at least when the major or minor version changes. The same is true if several versions are used simultaneously, e.g. a newer R version for a more recently started project and and older version for another project (but eventually picking up libraries built with the newer R version). |
|||
Standard usage: |
|||
Special care has also to be taken by users who always load the default version, i.e. |
|||
<pre> |
|||
Usage: R [options] [< infile] [> outfile] |
|||
R CMD command [arguments] |
|||
Example: R CMD BATCH script.R |
|||
</pre> |
|||
Executing R in batch mode: |
|||
<pre> |
<pre> |
||
$ module load math/R |
|||
R CMD BATCH --no-save --no-restore <INPUT_FILE>.R |
|||
</pre> |
</pre> |
||
as the default version number may change any time. It is therefore highly recommended to always load a specific version, e.g. |
|||
For help run |
|||
<pre> |
|||
R --help |
|||
</pre> |
|||
For command help run |
|||
<pre> |
<pre> |
||
$ module load math/R/3.6.3 |
|||
R CMD command --help |
|||
</pre> |
</pre> |
||
== Pre-installed R-packages == |
|||
Further informations and herlp_ |
|||
* Rmpi |
|||
<pre> |
|||
* Rcpp (R 4.4.1 only) |
|||
Man pages: 'man R' and 'man Rscript' |
|||
* RcppEigen (R 4.4.1 only) |
|||
Info pages. e.g.: 'info R-intro' or 'info R-FAQ' |
|||
* iterators |
|||
Manuals: $R_DOC_DIR/manual |
|||
* foreach |
|||
</pre> |
|||
* doMPI |
|||
* doParallel |
|||
* <s>cummeRbund</s> (see [https://wiki.bwhpc.de/e/BwUniCluster2.0/Software/R/cummeRbund '''installation instructions'''] below) |
|||
== Optional packages for R == |
|||
The following guides provide detailed instructions about how to build selected optional R packages on '''bwUniCluster''' for '''R version 4.1.2'''. Please write a [https://bw-support.scc.kit.edu/ ticket] if the instructions do not work for you or are outdated. |
|||
== Examples == |
|||
As with all processes that require more than a few minutes to run, non-trivial compute jobs must be submitted to the cluster queuing system. |
|||
Example scripts are available in the directory $R_EXA_DIR: |
|||
<pre> |
|||
$ module show math/R # show environment variables, which will be available after 'module load' |
|||
$ module load math/R # load module |
|||
$ ls $R_EXA_DIR # show content of directory $R_EXA_DIR |
|||
$ cat $R_EXA_DIR/README # show examples README |
|||
</pre> |
|||
Run a first simple example job |
|||
<pre> |
|||
$ module load math/R # load module |
|||
$ mkdir Rtest # create test directory |
|||
$ cp $R_EXA_DIR/bwhpc-r.moab $R_EXA_DIR/fit.R Rtest/ # copy example files to test directory |
|||
$ cd Rtest/ # change to directory |
|||
$ nano bwhpc-r.moab # change job options, quit with 'CTRL+X' |
|||
$ msub bwhpc-r.moab # submit job |
|||
$ checkjob -v <JOBID> # check state of job |
|||
$ ls # when job finishes the results will be visible in this directory |
|||
</pre> |
|||
== Installing R-Modules into your home folder == |
|||
Since we cannot provide an software module for every R package we recommend to install special R packages locally into you home folder. One possibility how to do this is shown below. |
|||
<pre> |
|||
$ cp $HOME/.bashrc $HOME/.bashrc.backup |
|||
$ echo "export R_LIBS=\"${HOME}/R_libs\"" >> $HOME/.bashrc |
|||
$ source $HOME/.bashrc |
|||
$ mkdir $R_LIBS |
|||
$ module load math/R |
|||
$ R |
|||
$ install.packages('package_name', repos="http://cran.r-project.org") |
|||
</pre> |
|||
You can restore your old .bashrc if something goes wrong with: |
|||
<pre> |
|||
mv $HOME/.bashrc.backup $HOME/.bashrc |
|||
</pre> |
|||
== Version-Specific Information == |
|||
For information specific to a single version, see the information available via the module system with the command |
|||
<pre> |
|||
$ module help math/R |
|||
</pre> |
|||
* [[BwUniCluster2.0/Software/R/Rgdal (R 4.2.1)]] |
|||
* [[BwUniCluster2.0/Software/R/Rgdal]] |
|||
* [[BwUniCluster2.0/Software/R/Rjags]] |
|||
* [[BwUniCluster2.0/Software/R/Rstan]] |
|||
* [[BwUniCluster2.0/Software/R/Glmnet]] |
|||
* [[BwUniCluster2.0/Software/R/stringi]] |
|||
* [[BwUniCluster2.0/Software/R/terra (R 4.2.1)]] |
|||
* [[BwUniCluster2.0/Software/R/terra]] |
|||
* [[BwUniCluster2.0/Software/R/cummeRbund]] |
|||
<br> |
|||
[[Category:Mathematics software]][[Category:bwUniCluster]] |
Latest revision as of 15:18, 30 October 2024
The main documentation is available via |
Description | Content |
---|---|
module load | math/R |
License | GPL |
Citing | n/a |
Links | Homepage | Documentation |
Graphical Interface | No |
Plugins | User dependent |
Description
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.
One of R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.
R is available as Free Software under the terms of the Free Software Foundation’s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and MacOS.
Usage
The R installation also provides the standalone library libRmath. This library allows you to access R routines from your own C or C++ programs (see section 9 of the 'R Installation and Administration' manual).
Installing R-Packages into your home folder
Since we cannot provide a software module for every R package, we recommend to install special R packages locally into your home folder. One possibility doing this is from within an interactive R session:
> library() # List preinstalled packages > install.packages('package_name', repos="http://cran.r-project.org") # Installing your R package and the dependencies > library(package_name) # Loading the package into you R instance
The package is now installed permanently in your home folder and is available every time you start R.
Note:
By default R uses a version (and platform) specific path for personal libraries, such as "$HOME/R/x86_64-pc-linux-gnu-library/x.y" for R version x.y.z. This directory will be created automatically (after confirmation) when installing a personal package for the first time.
Users can customize a common location of their personal library packages, e.g. ~/R_libs, rather than the default location. A customized directory must exist before installing a personal package for the first time, i.e.
$ mkdir -p ~/R_libs
The location must also be defined in a configuration file ~/.Renviron within the home directory containing the following line:
R_LIBS_USER="~/R_libs"
By setting up a (fixed) custom location for personal library packages, any personal package installed into that directory will be visible across different R versions. This may be advantageous if the packages are to be used with different (future) R versions.
A version specific path, such as the default path, allows users to maintain multiple personal library stacks for different (major and minor) R versions and does also prevent users from mixing their stack with libraries built with different R versions.
The drawback is that, whenever switching to a new R release, the personal library stack must be rebuilt with that new R version into the corresponding (version specific) library path. This is considered good practice anyway in order to ensure a consistent personal library stack for any specific R version in use. Mixing libraries built with different major and minor R versions is discouraged, as this may (or may not) result in unpredictable and subtle errors. Packages that are built and installed with one version of R may be incompatible with a newer version of R, at least when the major or minor version changes. The same is true if several versions are used simultaneously, e.g. a newer R version for a more recently started project and and older version for another project (but eventually picking up libraries built with the newer R version).
Special care has also to be taken by users who always load the default version, i.e.
$ module load math/R
as the default version number may change any time. It is therefore highly recommended to always load a specific version, e.g.
$ module load math/R/3.6.3
Pre-installed R-packages
- Rmpi
- Rcpp (R 4.4.1 only)
- RcppEigen (R 4.4.1 only)
- iterators
- foreach
- doMPI
- doParallel
cummeRbund(see installation instructions below)
Optional packages for R
The following guides provide detailed instructions about how to build selected optional R packages on bwUniCluster for R version 4.1.2. Please write a ticket if the instructions do not work for you or are outdated.
- BwUniCluster2.0/Software/R/Rgdal (R 4.2.1)
- BwUniCluster2.0/Software/R/Rgdal
- BwUniCluster2.0/Software/R/Rjags
- BwUniCluster2.0/Software/R/Rstan
- BwUniCluster2.0/Software/R/Glmnet
- BwUniCluster2.0/Software/R/stringi
- BwUniCluster2.0/Software/R/terra (R 4.2.1)
- BwUniCluster2.0/Software/R/terra
- BwUniCluster2.0/Software/R/cummeRbund