MacOS Installation

NOTE:

This guide shows you how to install on MacOS via the gdsr

Installation

Requirements

To be able to complete this guide, your machine will need to meet the following requirements:

  1. A stable internet connection
  2. ~10GB of space on your hard drive
  3. MacOS version 10.13 or newer i.e. High Sierra, Mojave, Catalina or Big Sur. If you are unsure what version you are running click on the Apple icon in the top left of the screen and then About this Mac.
  4. Mac hardware must be a 2010 model or newer

Docker install steps

  1. Go to the dockerhub website.
  2. Ensure you meet the criteria for download (it is the same as stated above) and then select ‘Get Docker’ button.


  1. This will then download to your machine but may take some time. Once finished, to access this download go to Finder > Downloads > Docker.dmg and double click.


  1. You should then be prompted to drag and drop this application into the applications folder like so:

You may get further windows asking for access to the program. To these you can click Open > OK > enter your account password and click Install helper


  1. After you have done this, the whale icon should now show in your taskbar:


You have successfully downloaded Docker!

Using Docker

Now we have Docker installed we can use it to access Python and all the associated packages we need for the practicals

Installing the GDSR environment

  1. Access your terminal: Launchpad > Other > Terminal
  2. In a fresh line in the terminal type the following to install the GDSR environment container:
docker pull darribas/gdsr:1.0


  1. This should now prompt a long download process that looks a bit like this: Don’t be alarmed if it seems to take a very long time.

IMPORTANT:

Make sure you are connected to the internet and it is a stable connection. This step involves the download of large amounts of data (ca. 5.5GB) so it might take a while. However, it only needs to be run once.

Check success

You will know the process has completed successfully when each line says ‘Pull complete’ and the new line shows your machine name.

If everything has gone according to plan, you should see darribas/gdsr:1.0 show up on your terminal when you type docker image ls (NOTE in the image below there are other containers that are not required, do not worry if you don’t have those or slightly different values on the ID and the “CREATED” columns, the important bit is having darribas/gdsr:1.0 listed):


Running RStudio

The following sections cover how to spin up a session you have just installed, use it, and shut it down when you are done.

Running the container

  1. In the new terminal line, type the following command to run the container:

docker run -d -e PASSWORD=test123 -p 8787:8787 -v "${PWD}":/home/rstudio/work darribas/gdsr:1.0


You have now started a RStudio session.

IMPORTANT:

Please do NOT close the terminal window until you are finished in this RStudio session

  1. The following window will appear (If this doesn’t happen, go to 5):

  1. Go to System Preferences > Security & Privacy. The following window will appear:

  1. Click the lock (shown above) and enter your password.

  2. Now you can access the RStudio session. Go to your chosen web browser (e.g. Safari/Chrome) and type: localhost:8787 into the search bar

  1. The page that loads will prompt you for a username and password as shown above. Type the following (as on the figure above):

username: rstudio

password: test123


  1. Now you are in RStudio Server, you can start coding or opening a new file. Please refer to Rowe and Arribas-Bel (2021) for an introduction to the RStudio interface, R Script and R Notebook.


Using a R Notebook

  • A R notebook is where you will run your code and can add text. The top header is called YAML metadata and each shaded box is called a kernel (or code chunk) contained within delimiters ```{r} and ```.

  • Type 1 + 1 into a code chunk. To run the code click the play icon as indicated below.


IMPORTANT:

Make sure you save your files by you want to keep ONLY within the work folder, as this will ensure they are saved on your machine.

Everything saved outside the work folder will be destroyed as soon as you shut down the session.

  • You can access other files on your machine through the work folder in the Files Browser. From here you can navigate to your Documents and designated folder for this module.

Here I am navigating to the san folder that we have created for this module in my Downloads. You can replace this with the pathway to the folder you create for this module.


  • You can save your notebook here using File > Save As


  • And you can create new folders to organise your work


Ending your session

Once you have finished in your RStudio session and have saved all your work, you can end the session by closing your browser.

  1. Run docker ps:

  1. Then, type docker container rm or docker container stop, and copy the CONTAINER ID from the output above as shown here:


You can now safely shut the terminal window.


Next time you go to run a R Notebook you will NOT need to repeat the whole process as you have already installed Docker and the GDSR environment. Instead you can start from Running the container and carry on from there.