Difference between revisions of "Software:R"

From CAC Wiki
Jump to: navigation, search
(Installing R packages)
(Installing R packages)
Line 35: Line 35:
 
Typically, one needs to load a corresponding gcc compiler before loading R. Note: StdEnv/2020 modules contains gcc/9.3.0 and is sufficient to load r/4.1.2
 
Typically, one needs to load a corresponding gcc compiler before loading R. Note: StdEnv/2020 modules contains gcc/9.3.0 and is sufficient to load r/4.1.2
  
== Installing R packages ==
+
== Installing R packages(Under Construction) ==
  
Each R modules comes with base R packages and might not have all the required packages for your project. You can additional packages from CRAN using the install.packages() command. By default, R tries to install this packages in the folder the R is install.
+
Each R modules comes with base R packages and might not have all the required packages for your project. You can additional packages from CRAN using the install.packages() command. By default, R tries to install this packages in the folder where R was install, $EBROOTR. Since users don't have the write permission to modify this folder in /cvmfs software stack, you will be prompted to install the R packages in your local directory. Please type "yes" and type enter.
 +
 
 +
Several R packages use GNU compilers during the installation, so it generally recommend load gcc module along with the R module.
 +
{{Command
 +
|$ module load StdEnv/2020
 +
|$ module load gcc/9.3.0 r/4.0.2
 +
|$ R
 +
|> install.packages('sp', repos='https://cloud.r-project.org/')
 +
|Warning in install.packages("sp", repos = "https://cloud.r-project.org/") :
 +
|  'lib = "/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/Core/r/4.0.2/lib64/R/library"' is not writable
 +
|Would you like to use a personal library instead? (yes/No/cancel) yes
 +
|Would you like to create a personal library
 +
|‘~/R/x86_64-pc-linux-gnu-library/4.0’
 +
|to install packages into? (yes/No/cancel) yes
 +
|...
 +
|
 +
|>
 +
}}

Revision as of 19:51, 10 June 2022

Introduction

R is a language and environment for statistical computing and graphics. It 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. Although R is not well-suited for HPC cluster, functionality and flexibility for data handling and analysis make it a essential tool for researcher from wide range of scientific discipline. In addition, R provide a large repository of user built packages suits for different range of applications.

You can run your R script from our Rstudio or through a batch script on compute nodes. Rstudio provides our user with an IDE to develop and run your program on a web browser. But it is constrained in term of the available packages and the compute resource. Alternative, you can run the program through command line /batch script which provides the user the flexibility to choose the different version of R available on our central software stack and their respective packages. This pages focus on primer for running Rscript on compute nodes.

Starting R console

Similar to any software stack on the cluster, based on the requirement one needs to load a specific version of R using the 'module load' command. You can load default version using

 $ module load r

Use module spider command to list all the different version and their dependencies.

$ module spider r

Several version of R are available as module(r/3.3.3 to 4.1.2). You need to load all the dependent modules before load a specif r version and can be determine using module spider command $ module spider r/4.1.2

   You will need to load all module(s) on any one of the lines below before the "r/4.1.2" module is available to load.
     StdEnv/2020

Now you can load r/4.1.2 using the following module load commands

$ module load StdEnv/2020
$ module load r/4.1.2

Similarly, if you want to load r/3.6.1

$ module spider r/3.6.1
$ module load  nixpkgs/16.09  gcc/7.3.0
$ module load r/3.6.1

Typically, one needs to load a corresponding gcc compiler before loading R. Note: StdEnv/2020 modules contains gcc/9.3.0 and is sufficient to load r/4.1.2

Installing R packages(Under Construction)

Each R modules comes with base R packages and might not have all the required packages for your project. You can additional packages from CRAN using the install.packages() command. By default, R tries to install this packages in the folder where R was install, $EBROOTR. Since users don't have the write permission to modify this folder in /cvmfs software stack, you will be prompted to install the R packages in your local directory. Please type "yes" and type enter.

Several R packages use GNU compilers during the installation, so it generally recommend load gcc module along with the R module.

<syntaxhighlight lang="bash">[name@server ~]$ $ module load StdEnv/2020 </syntaxhighlight>