For all operating systems
Install a good text editor
Before you start, it is handy to dispose of a jack-of-all-trades text editor.
Sublime Text is a flexible platform agnostic text editor for code and markdown syntax. For instance, it can open R scripts and markdown.md
text files and color-code their languages accordingly.
- Go to the Sublime Text download page.
- Select your OS (Linux, Mac or Windows) and install it.
What needs to be installed are the R and RStudio softwares as well as related R packages. You will also have to install the version control git
software. There are two different options for you to consider. Option 1 is favored.
Option 1: using a Docker image
The preferred option to install all softwares and packages is to use a tailor-made Docker image. See this nice introduction to Docker here.
This image is based on the rocker verse Docker image image with three extra R libraries (skimr
, plotly
and nycflights13
). The latest image can be found at the Science Park Study Group DockerHub.
Before you start
Before the training, please make sure you have done the following:
- First, install Docker desktop for your operating system. You can find more installation instructions here if this fails.
- If needed, install Shell Bash: follow these instructions.
- Open a new Shell Bash window and navigate to a folder that will be your workspace. For instance, you could create a folder named
r-tutorial/
on your Desktop and move inside with the Shell usingcd ~/Desktop/r-tutorial/
.- In a Shell Bash window, type the following command:
docker run --rm --name rstudio_instance -v $PWD:/home/rstudio/ -e PASSWORD=mypwd -p 8787:8787 scienceparkstudygroup/master-gls:openr-latest
. This will download a Docker image for the course, create and run a container where RStudio will be running.- Navigate to http://localhost:8787 in your web browser. You should have an RStudio session running. Type
rstudio
as the user name andmypwd
as your password.- To quit, close the web browser window where RStudio is running and exit the Shell too.
Important note
You can save files to your disk when working inside the Docker-powered R session. You need to save them as you would normally. The files (e.g.
my_plot.png
) will be where you were working (the directory from which you launched the Docker container). If you were
Docker command-line explanations:
- The
--rm
removes the container when it has been run. No need to store it into your computer after use. - The
--name
gives a name to the running container for easy retrieval. - The
-p 8787:8787
follow the format-p host_port:container_port
. Therefore the port 8787 inside the container will be exposed to the outside port on the host machine. That way, the running instance of RStudio can be access through the:port format.
Option 2: manual installation
This is the second way to install softwares and packages. It should work but there is no guarantee that it will work since R and packages versions on your machine might be different from the software and package versions used in this lesson. Thus, the preferred way is still to use the Docker image (option 1).
Before you start
Before the training, please make sure you have done the following:
- Download and install up-to-date versions of:
- Within R/RStudio, install these packages:
tidyverse
skimr
plotly
nycflights13
To do so, open R and use the
install.packages()
function.install.packages("tidyverse") install.packages("skimr") install.packages("plotly") install.packages("nycflights13")