R and RStudio ============= R is available through the Spack package manager with support for statistical computing, CRAN package management, and RStudio IDE. .. contents:: Table of Contents :local: :depth: 2 R Quick Start ------------- .. note:: For the value of ``${SPACK_ROOT}``, Please refer to :ref:`Spack Instances ` for the installation path. .. code-block:: bash # Modify this path accordingly export SPACK_ROOT="/path/to/spack" # Activate Spack environment source "${SPACK_ROOT}/dist/bin/setup-env.sh" -y # Check available R versions module avail r # Load R module load r/4.4 # Verify installation R --version # Start R R # Interactive mode R --quiet --no-save # Quiet mode # Run a script Rscript my_script.R .. note:: Module names may include a 7-digit hash suffix (e.g., ``r/4.4.2-4pchx4a``). You do **NOT** need to include this hash when loading - the version alone (e.g., ``4.4``) is sufficient. RStudio Quick Start ------------------- .. note:: For the value of ``${SPACK_ROOT}``, Please refer to :ref:`Spack Instances ` for the installation path. .. code-block:: bash # Modify this path accordingly export SPACK_ROOT="/path/to/spack" # Activate Spack environment source "${SPACK_ROOT}/dist/bin/setup-env.sh" -y # Load RStudio (will automatically load R 4.x) module load rstudio # Or explicitly specify R version (recommended) module load r/4.4 module load rstudio # Launch RStudio (requires GUI/X11) rstudio .. note:: RStudio will automatically load a compatible R 4.x backend if you don't specify one. However, it's recommended to explicitly load your preferred R version first to ensure consistency. Tutorials --------- .. toctree:: :maxdepth: 1 :titlesonly: Features Availability --------------------- .. list-table:: :header-rows: 1 :widths: 30 20 20 30 * - Feature / Version - R 3.x - R 4.x - RStudio 2024 * - **Installed** - ✗ - ✓ - ✓ * - **R Interpreter** - Not supported - ✓ - R 4.x only * - **Rscript Command** - ✗ - ✓ - N/A * - **CRAN Package Manager** - ✗ - ✓ - ✓ * - **SLURM Compatibility** - ✗ - ✓ - ✗ Environment Variables --------------------- When loading the R module, the following environment variables are set automatically. R_HOME ^^^^^^ Points to the R installation directory. **Default:** ``/rlib/R`` R_LIBS_USER ^^^^^^^^^^^ Specifies the user-specific library directory for R packages. Packages installed via ``install.packages()`` are stored here. **Default:** ``$HOME/.R/R---/library`` .. note:: These environment variables are automatically configured when you load the R module. You typically don't need to modify them manually. Support and Resources --------------------- **R Documentation** - `R Documentation `_ - `CRAN (Comprehensive R Archive Network) `_ - `renv Documentation `_ - `Bioconductor `_ **RStudio Documentation** - `RStudio Documentation `_ - `RStudio IDE Guide `_