Working with R¶
R is available as a module (see Using Module for more information) and it is also an interactive app on Open onDemand (see Introduction to Open OnDemand (OOD) for more information). You can also use R with Anaconda. See Working with Conda/Miniconda/Anaconda and the Anaconda documentation for more information
If you work with R packages, using a Packrat environment can be helpful. Use the procedure below to create a Packrat environment on Discovery.
Creating a Packrat Environment (for R)¶
Packrat is an application that helps you manage packages for R. After you create a new directory for your R project, you can then use Packrat to store your package dependencies inside it. For more information about Packrat, see the website: https://rstudio.github.io/packrat/.
Connect to Discovery.
module load R/3.6.2.
Create a new directory for your R project by typing,
yourusernameis your user name, and
directorynameis the name of the directory you want to create for your R project. For example,
Open the R interface and install Packrat:
install.packages("packrat") #during the installation, you will be prompted to install in a local directory, as you cannot install as root
Initialize the environment where R packages will be written to:
You can then install R packages that you need. For example, to install a package called
rtracklayer, type the following:
if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("rtracklayer")