Difference between revisions of "Applications/R"
m |
m (→Usage Examples) |
||
(16 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
==Application Details== | ==Application Details== | ||
− | * Description: R is an open source programming language and software environment for statistical computing | + | * Description: R is an open-source programming language and software environment for statistical computing & graphics |
− | * Version: 3.3.0, 3.4.1 | + | * Version: 3.3.0, 3.4.1, 3.5.1, 4.0.2 and 4.2.2 |
− | * Modules: R/3.3.0,R/3.4.1 | + | * Modules: R/3.3.0,R/3.4.1, R/3.5.1, R/4.0.2 and R/4.2.2 |
* Licence: GNU | * Licence: GNU | ||
Line 13: | Line 13: | ||
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. | 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. | ||
+ | |||
+ | * [[Programming/R|R Programming Support]] | ||
+ | * [[Applications/RStudio|R Studio]] is provided as an interactive module as well. | ||
==Usage Examples== | ==Usage Examples== | ||
Line 20: | Line 23: | ||
===Interactive=== | ===Interactive=== | ||
− | '''Note''': R supports interactive mode (as below | + | '''Note''': R supports interactive mode (as below, don't run this on the login node and execution mode running as an interpreted script. |
<pre style="background-color: black; color: white; border: 2px solid black; font-family: monospace, sans-serif;"> | <pre style="background-color: black; color: white; border: 2px solid black; font-family: monospace, sans-serif;"> | ||
Line 26: | Line 29: | ||
[username@login01 ~]$ interactive | [username@login01 ~]$ interactive | ||
salloc: Granted job allocation 402968 | salloc: Granted job allocation 402968 | ||
− | Job ID | + | Job ID 4029681 connecting to c059, please wait... |
− | Last login: Wed Jul 12 16:23:48 | + | Last login: Wed Jul 12 16:23:48 2020 from 10.254.5.246 |
− | [username@c059 ~]$ module add R/ | + | [username@c059 ~]$ module add R/4.2.2 |
[username@c059~]$ R | [username@c059~]$ R | ||
</pre> | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<strong>Install an R package</strong> | <strong>Install an R package</strong> | ||
Line 54: | Line 41: | ||
<pre style="background-color: black; color: white; border: 2px solid black; font-family: monospace, sans-serif;"> | <pre style="background-color: black; color: white; border: 2px solid black; font-family: monospace, sans-serif;"> | ||
+ | [pysdlb@login01 ~]$ interactive | ||
+ | salloc: Granted job allocation 3039458 | ||
+ | Job ID 3039458 connecting to c120, please wait... | ||
+ | [pysdlb@c120 ~]$ module load R/4.2.2 | ||
+ | [pysdlb@c037 ~]$ R | ||
− | + | R version 4.2.2 (2022-10-31) -- "Innocent and Trusting" | |
− | + | Copyright (C) 2022 The R Foundation for Statistical Computing | |
− | |||
− | |||
− | Copyright (C) | ||
Platform: x86_64-pc-linux-gnu (64-bit) | Platform: x86_64-pc-linux-gnu (64-bit) | ||
Line 65: | Line 54: | ||
You are welcome to redistribute it under certain conditions. | You are welcome to redistribute it under certain conditions. | ||
Type 'license()' or 'licence()' for distribution details. | Type 'license()' or 'licence()' for distribution details. | ||
− | |||
− | |||
R is a collaborative project with many contributors. | R is a collaborative project with many contributors. | ||
Line 76: | Line 63: | ||
Type 'q()' to quit R. | Type 'q()' to quit R. | ||
− | + | [Previously saved workspace restored] | |
+ | > install.packages('some package') | ||
+ | -------- | ||
</pre> | </pre> | ||
Line 92: | Line 81: | ||
module purge | module purge | ||
− | module add R/ | + | module add R/4.2.2 |
R CMD BATCH Random.R output.data | R CMD BATCH Random.R output.data | ||
Line 99: | Line 88: | ||
<pre style="background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;"> | <pre style="background-color: #000000; color: white; border: 2px solid black; font-family: monospace, sans-serif;"> | ||
[username@login01 ~]$ sbatch Rtest.job | [username@login01 ~]$ sbatch Rtest.job | ||
− | Submitted batch job | + | Submitted batch job 28952211 |
</pre> | </pre> | ||
− | '''Note''': the output from the R interpreter will appear in the file output | + | '''Note''': the output from the R interpreter will appear in the file output data is stated. |
==Further Information== | ==Further Information== | ||
Line 108: | Line 97: | ||
* [[Programming/R|R Programming Support]] | * [[Programming/R|R Programming Support]] | ||
* [http://www.rexamples.com/ http://www.rexamples.com/] | * [http://www.rexamples.com/ http://www.rexamples.com/] | ||
+ | |||
+ | {{Modulepagenav}} |
Latest revision as of 14:23, 18 January 2023
Contents
Application Details
- Description: R is an open-source programming language and software environment for statistical computing & graphics
- Version: 3.3.0, 3.4.1, 3.5.1, 4.0.2 and 4.2.2
- Modules: R/3.3.0,R/3.4.1, R/3.5.1, R/4.0.2 and R/4.2.2
- Licence: GNU
Information
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 non-linear 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 Programming Support
- R Studio is provided as an interactive module as well.
Usage Examples
Note: Use version 3.4.1, version 3.3.0 will be deprecated in the future.
Interactive
Note: R supports interactive mode (as below, don't run this on the login node and execution mode running as an interpreted script.
[username@login01 ~]$ interactive salloc: Granted job allocation 402968 Job ID 4029681 connecting to c059, please wait... Last login: Wed Jul 12 16:23:48 2020 from 10.254.5.246 [username@c059 ~]$ module add R/4.2.2 [username@c059~]$ R
Install an R package
[pysdlb@login01 ~]$ interactive salloc: Granted job allocation 3039458 Job ID 3039458 connecting to c120, please wait... [pysdlb@c120 ~]$ module load R/4.2.2 [pysdlb@c037 ~]$ R R version 4.2.2 (2022-10-31) -- "Innocent and Trusting" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] > install.packages('some package') --------
Batch Submission
#!/bin/bash #SBATCH -J My_R_job # Job name, you can change it to whatever you want #SBATCH -N 1 # Number of nodes #SBATCH -o %N.%j.out # Standard output will be written here #SBATCH -e %N.%j.err # Standard error will be written here #SBATCH -p compute # Slurm partition, where you want the job to be queued #SBATCH --exclusive # run on one node without any other users #SBATCH --mem=64G # reserve 64Gbytes of RAM for my job (optional) module purge module add R/4.2.2 R CMD BATCH Random.R output.data
[username@login01 ~]$ sbatch Rtest.job Submitted batch job 28952211
Note: the output from the R interpreter will appear in the file output data is stated.