Skip to content

Instantly share code, notes, and snippets.

View jalapic's full-sized avatar

James Curley jalapic

View GitHub Profile
# function to do a dodged half-boxplot and jittered points next to each other
#
# data_in should be a data frame
# factor_col should be a bare column name (not a string)
# although it will work if that column is factor or a character type
# numeric_col is the y axis continuous variable
# offset is the width of the boxplots and jittered point cloud
#
# the basic approach is to draw a boxplot without the tails
# (e.g. only the interquartile range) and then use segments to add the
@johnburnmurdoch
johnburnmurdoch / mourinho_clubelo.R
Created December 18, 2018 17:57
Scripts for downloading and visualising data from clubelo.com showing José Mourinho’s third season problem. A hand-finished version of this chart appears in this Financial Times story: https://www.ft.com/content/56acdd82-02d2-11e9-99df-6183d3002ee1
needs(tidyverse, magrittr, scales)
jose.porto <- read_csv("http://api.clubelo.com/porto")
jose.chelsea <- read_csv("http://api.clubelo.com/chelsea")
jose.inter <- read_csv("http://api.clubelo.com/inter")
jose.real <- read_csv("http://api.clubelo.com/realmadrid")
jose.mufc <- read_csv("http://api.clubelo.com/manunited")
jose.all <- bind_rows(
jose.porto %>% filter(From >= as.Date("2002-01-22") & To <= as.Date("2004-06-30")),