---
# System prepended metadata

title: SIPS Workshop - Reproducible Data Visualizations Using R and Binder. <br>July 8th 11.30-12.15 and 13.30-16.15

---

# SIPS Workshop - Reproducible Data Visualizations Using R and Binder. <br>July 8th 11.30-12.15 and 13.30-16.15
![](http://ajstewartlang.github.io/images/Twitter.png =50x50) @ajstewart_lang
![](http://ajstewartlang.github.io/images/Twitter.png =50x50) @psytecholi

# Slides from this Morning
http://ajstewartlang.github.io/SIPS_2019/SIPS_presentation.html

<br>

# Loading the Data
The data for the 6 visualizations are from a Tidy Tuesday dataset: 

<i>The SNCF (National Society of French Railways) is France's national state-owned railway company. Founded in 1938, it operates the country's national rail traffic along with Monaco, including the TGV, France's high-speed rail network. This dataset covers 2015-2018 with a lot of different train stations. The dataset primarily covers aggregate trip times, delay times, cause for delay, etc for each station - lots of different ways to approach the full_trains.csv dataset with its 27 columns!</i>

You can download the dataset and map it onto a variable like this:

`full_trains <- read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-02-26/full_trains.csv")`

# Visualization Challenges
For the following 6 visualizations:

## Step 1
Write the code in an R script that will generate each visualization. 

## Step 2
Push or upload your script to a new GitHub repository (see steps below) alongwith a `runtime.txt` and `install.R` file.

## Step 3
Generate a new Binder from your new repo (see steps below).

## Repeat for each visualization 

At the end of the workshop today, you should have 6 scripts, each saved in their own repository on GitHub, and 6 Binders - one associated with each of your 6 repositories.


## Visualization Challenge 1
ajstewartlang.github.io/SIPS_2019/visualizations/script_vis_1.html

## Visualization Challenge 2
ajstewartlang.github.io/SIPS_2019/visualizations/script_vis_2.html

## Visualization Challenge 3
ajstewartlang.github.io/SIPS_2019/visualizations/script_vis_3.html

## Visualization Challenge 4
ajstewartlang.github.io/SIPS_2019/visualizations/script_vis_4.html

## Visualization Challenge 5
ajstewartlang.github.io/SIPS_2019/visualizations/script_vis_5.html

## Visualization Challenge 6
ajstewartlang.github.io/SIPS_2019/visualizations/script_vis_6.html

---

# Setting up a Binder
Set up a Binder and a separate GitHub repository for each of your 6 data viz scripts.
## Step 1
Set up a free account on [GitHub](https://www.github.com) if you don't already have one.

## Step 2
In GitHub, create a new repository, make sure it's public (not private) and initialize it with a `README.md`

## Step 3
Upload your R script to your newly created repository (repo) on GitHub. Don't forget to click on 'Commit' once it's uploaded. 

## Step 4
In your repo, create a new file called `runtime.txt`

In this file, add one line of text in the format: `r-YYYY-MM-DD`

For example: `r-2019-06-07`

This is the date that Binder uses to pull the appropriate packages from MRAN (the time stamped version of CRAN).  Remember to commit.

## Step 5
In your repo, create a new file called `install.R`

In this file, list the packages that you want installed such as:

`install.packages("ggplot2")`
`install.packages("dplyr")`


As the whole tidyverse can take a long time to build, you're better off specifying the individual packages that you use rather than loading the entire tidyverse. 

Remember to commit.

## Step 6
Now go to [mybinder.org](https://mybinder.org)

Paste the address of your newly created GitHub repo under "GitHub repository name or URL".

Type `rstudio` in lower case into the `Path to a notebook file (optional)` box.

Make sure you then select `URL` and not `File` to the right of that.

Now you're ready to go. Click `launch`!

To follow progress, click on the `Build logs` bar.

# Links to your Binders
Once your Binder is built please add a link to it below. You can edit this document by click on either the pencil or book icon in the top left. If you click on the book icon, you can use the editor in the left pane and the text that you add wil be rendered in the right pane.

During this afternoon's session, I'll add a link to each of the 6 Binders I have built containing the code for each of the 6 visualizations. That way you can see how I coded each visualization.

## Visualization 1 Binders
Andrew - https://mybinder.org/v2/gh/ajstewartlang/SIPS_visualisation_1/master?urlpath=rstudio

Ellie - https://mybinder.org/v2/gh/ellieha/bindervis1/master?urlpath=rstudio

Maike - https://mybinder.org/v2/gh/MaikeLD17/Binder1/master?urlpath=rstudio

Lilach - https://mybinder.org/v2/gh/lilachdh/Visualization-1/master?urlpath=rstudio

Lilian - https://mybinder.org/v2/gh/lilianjansbeken/SIPS2019datavizualization/master?urlpath=rstudio

Anne-Wil - 

Elena - https://mybinder.org/v2/gh/bassible/Visualization-1.git/master?urlpath=rstudio

Feni - 
https://mybinder.org/v2/gh/kontogif/first_binder/master?urlpath=rstudio

Laura - https://mybinder.org/v2/gh/laurabotzet/tryingoutbinder_v1.git/master?urlpath=rstudio

Eirini - https://mybinder.org/v2/gh/eirini-zormpa/SIPS2019-reproducible_dataviz/master?urlpath=rstudio

Jonas (left early, stat_bin()) - https://hub.gke.mybinder.org/user/grszkthfr-sips2019_data-vis-qtys2jsu/rstudio/

Pierpaolo - https://mybinder.org/v2/gh/pierpri/binder_1/master?urlpath=rstudio

## Visualization 2 Binders

Andrew - https://mybinder.org/v2/gh/ajstewartlang/SIPS_visualisation_2/master?urlpath=rstudio

Lilian - https://mybinder.org/v2/gh/lilianjansbeken/SIPS2019datavizualization/master?urlpath=rstudio

Laura - https://mybinder.org/v2/gh/laurabotzet/tryingoutbinder_v2.git/master?urlpath=rstudio

Eirini - https://mybinder.org/v2/gh/eirini-zormpa/SIPS2019-reproducible_dataviz/master?urlpath=rstudio

Pierpaolo - https://mybinder.org/v2/gh/pierpri/binder_2/master?urlpath=rstudio

## Visualization 3 Binders

Andrew - https://mybinder.org/v2/gh/ajstewartlang/SIPS_visualisation_3/master?urlpath=rstudio

Laura - https://mybinder.org/v2/gh/laurabotzet/tryingoutbinder_v3.git/master?urlpath=rstudio

Pierpaolo - https://mybinder.org/v2/gh/pierpri/binder_3/master?urlpath=rstudio

Elena - https://mybinder.org/v2/gh/bassible/visualisation3.git/master?urlpath=rstudio

Eirini - https://mybinder.org/v2/gh/eirini-zormpa/SIPS2019-reproducible_dataviz/master?urlpath=rstudio

## Visualization 4 Binders

Laura - https://mybinder.org/v2/gh/laurabotzet/tryingoutbinder_v4.git/master?urlpath=rstudio
Elena - https://mybinder.org/v2/gh/bassible/visualisation4.git/master?urlpath=rstudio

## Visualization 5 Binders

Andrew - https://mybinder.org/v2/gh/ajstewartlang/SIPS_visualisation_5/master?urlpath=rstudio

## Visualization 6 Binders

Andrew - https://mybinder.org/v2/gh/ajstewartlang/SIPS_visualisation_6/master?urlpath=rstudio

# Advanced Binder - Using Karthik Ram's holepunch package in RStudio

If you're comfortable with using git and GitHub, you might be interested in trying the holepunch package. This will allow you to use a pre-built R Docker image and is a lot faster than building your Binder from scratch. It's a little more involved, however, so I'd only recommend you try this if you're comfortable with using git locally and pushing to GitHub. 

My step-by-step guide is here:

https://ajstewartlang.github.io/SIPS_2019/holepunch.pdf

