CSC Computing Environment

R on Puhti and package installations

💬 A pre-installed R environment is available on Puhti.

  1. To check available module versions, run:
module spider r-env
  1. There are several ways to use R in r-env on Puhti:

For example, to launch the R console in an interactive job, open a shell with sinteractive and then

module load r-env

💡 See the r-env documentation for further instructions on different ways to launch R on Puhti.

💬 It is also possible to install R packages yourself.

How to install an R package on Puhti

  1. Create a folder for your R packages in /projappl (open a login node shell in the Puhti web interface or log in to Puhti with SSH):
# First navigate to /projappl/<project>, then
mkdir project_rpackages_<rversion>
  1. Start an R session (launch RStudio in the Puhti web interface or launch the R console in an interactive shell session: start the job with sinteractive -> module load r-env -> start-r). In R, add the folder you created above to the list of directories where R will look for packages:
.libPaths(c("/projappl/<project>/project_rpackages_<rversion>", .libPaths())) 

Assign libpath to point to this directory (not strictly necessary but can make life easier):

libpath <- .libPaths()[1]
  1. Install the package (again, defining lib = libpath to specify the installation location is not strictly necessary but recommended)
install.packages("packagename", lib = libpath)

For example, you can try installing a package called beepr with

install.packages("beepr", lib = libpath)

Finished! The R package is now ready to be loaded and used. Try loading beepr with library(beepr).

💡 The package location is defined only for the current R session! R has to be reminded of the location at the start of every R session or script where you want to use the project-specific package by running this command again:

.libPaths(c("/projappl/<project>/project_rpackages_<rversion>", .libPaths())) 

💡 Instead of installing a missing package for your own project, you can ask for a module-wide installation for all users by contacting servicedesk\

More information

💡 Read more about using R on Puhti in r-env documentation in Docs CSC.