Prerequisites

Knowledge prerequisites

The materials in this book assume that you already know something (but not necessarily a great deal) of the languages R and Python, so there won’t be any introduction to the languages themselves. The rest of this chapter will help you set up the software you need to practice with those tools.

Software prerequisites

You need to install the following stuff for this book:

  1. R
  2. RStudio
  3. Some R packages: rmarkdown, knitr
  4. Python 3 via Anaconda
  5. A reasonably recent web-browser

Installing R

Follow this link and install the right version for your operating system https://www.stats.bris.ac.uk/R/

Installing RStudio

Follow this link and install the right version for your operating system https://www.rstudio.com/products/rstudio/download/

Installing R packages in RStudio

Standard packages

In the RStudio console, type

install.packages(c("rmarkdown", "knitr"))

Installing Python 3 with Anaconda

Follow this link and install Python 3.x for your operating system. https://www.anaconda.com/distribution/

Note for macOS users

Accept all of the defaults during installation

Here is a video tutorial https://www.youtube.com/watch?v=TcSAln46u9U

Note for Windows users

Install Python 3 using all of the defaults for installation except make sure to check Add Anaconda to my PATH environment variable.

Here is a video tutorial https://www.youtube.com/watch?v=xxQ0mzZ8UvA

Note for Linux Users

You’ll need to be able to use the command-line to install with Anaconda. If you aren’t comfortable with this, ask for assistance from the local support team.

  1. Open https://www.anaconda.com/download/#linux with your web browser.
  2. Download the Python 3 installer for Linux.
  3. Open a terminal window. 4.Type bash Anaconda3-and then press Tab. The name of the file you just downloaded should appear. If it does not, navigate to the folder where you downloaded the file, for example with: cd Downloads. Then, try again.
  4. Press enter. You will follow the text-only prompts. To move through the text, press the spacebar.
  5. Type yes and press enter to approve the license.
  6. Press enter to approve the default location for the files.
  7. Type yes and press enter to prepend Anaconda to your PATH (this makes the Anaconda distribution the default Python).
  8. Close the terminal window.

Starting a Jupyter Notebook

macOS

  1. Start the Terminal application in Applications -> Utilities
  2. Type jupyter notebook, it should start in your web browser

Windows

  1. From the Start menu, search for and open Anaconda 3 or Jupyter Notebook. You should be able to start a notebook directly by clicking the Jupyter Notebook icon.

Linux

  1. Open the terminal application. It is usually in the task bar or dock
  2. Type jupyter notebook, it should start in your web browser

Installing Python Packages with conda

You can use conda to install new Python packages using the Terminal by typing conda install <package_name>.

You can install the required packages with the following commands:

conda install jupyter

Accept all defaults when the system asks a question.