How do I add code libraries to my Notebook?

SWAN comes with a default set of code libraries for R, Python, Octave and C++ programming languages.

Additional code libraries in these languages can be imported and installed in a Notebook to meet different research needs.

For example, in Python you can add spaCy for natural language data processing and NumPy for time series data processing. In R you can add ggplot2 for visualising data and dplyr for categorised data processing.



To add code libraries to your Notebook, please follow the instructions below.   


In order to install a Python library that is not already installed, run the following in your Notebook:

!pip install xarray

Where xarray is the name of the missing library.  


Installing an R library that is not already installed requires some extra setup:

#create a local folder for the local files to live in
#[Creates a folder call "R" in your CloudStor home] dir.create('/scratch/R', showWarnings = FALSE) #add the local folder to R's .libPaths(new='/scratch/R') #install a package (zip) locally install.packages("zip", lib="/scratch/R") #import the lib (zip) library(zip, lib="/scratch/R")

Where zip is the missing library


CloudStor SWAN is a shared environment. Code libraries must be installed in your local SWAN home folder (/scratch).

If you receive a “read-only file system” error you have attempted to install your package or libraries over the top of the pre-installed environment. Please ensure you are installing them in your home folder.

If you believe that the libraries are useful for others and are common, please let us know and we may include it in SWAN.