The base R package is provided on Arc via modules on the compute nodes. First, start an interactive session on a compute node by tpying:
srun -p compute1 -n 1 -t 00:05:00 --cpus-per-task=1 --pty bash
After you are connected to a compute node, you can load an R module using the following command:
module load R/4.1.0
R libraries can be installed in your home or work directories. The R libraries are installed in the home directory by default, typically /home/abc123/R/4.1.0 if the R/4/.1.0 module is loaded. However, you can change it to the work directory if you run out of space in the home directory. First, you need to create the directory in your work directory, such as R/4.1.0, (launch R first by typing "R" as shown below). Then use the command below to add this path to your R llibpath:
$ R
> .libPaths( c("/work/abc123/R/4.1.0", .libPaths()))
Then you can use the following command to install an R package (for example "ggplot2") to the new location:
> install.packages("ggplot2")