Skip to main content

Install devtools in R

devtools is a package that provides R functions to simplify many common tasks. It is commonly used to install packages from GitHub and other sources.

Important: Installing devtools is memory-intensive and installs many dependencies.

Installation Location

By default, packages install to $HOME/R/x86_64-pc-linux-gnu-library/<R_version>. This is a local installation specific to your Carina environment. If you are prompted to create this Personal Library folder, allow it.

Choose Your Installation Method

This web-based method is the easiest approach.

  1. Start an RStudio session

  2. Choose the Large size for sufficient memory

Launching an RStudio session on Carina
  1. Connect to your session from My Interactive Sessions
Running RStudio session on Carina
  1. In the RStudio Console, run:

    install.packages("devtools")

RStudio session on Carina
  1. If prompted, select a CRAN mirror

  2. Wait for the installation to complete (this may take several minutes)

Method 2: Command Line

This method gives you more control over resource allocation.

  1. Connect to Carina via SSH

  2. Request compute resources via Slurm’s srun command (cannot run on login nodes):

    srun -p normal -n 1 --cpus-per-task=8 --pty bash

    This requests one node with 8 CPUs on the normal partition.

  1. When you are on a computing node, load the R module. Note that R is an exception to the “all module names are lowercase” rule, and must be loaded with an uppercase R.

    Load the default version:

    module load R or ml R (module load and ml are interchangeable)

    Load a different version:

    ml R/4.4.3

  2. Start R:

    R

  3. Install devtools:

    install.packages("devtools")

    If prompted, choose a CRAN mirror and approve creating the Personal Library

Installing devtools via command line

Verify Installation

After installation completes, load the library to verify:

library(devtools)

If successful, you should see no errors. You can also check the version:

packageVersion("devtools")

Available R Versions

These R versions are available in Carina OnDemand and via module load:

  • R/4.3.3
  • R/4.4.3
  • R/4.5.1 (current default)

To use a specific version in OnDemand, select it in the session launch form. For command line, specify the version when loading the module, for example ml R/4.4.3.

Next Steps

With devtools installed, you can:

  • Install packages from GitHub: devtools::install_github("username/repo")
  • Install from local sources
  • Access development tools for creating your own packages

See the devtools documentation for full functionality.