Skip to content

Instantly share code, notes, and snippets.

@jalapic
Created April 17, 2018 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jalapic/e9ede23a3849c2d012690842e98f09cc to your computer and use it in GitHub Desktop.
Save jalapic/e9ede23a3849c2d012690842e98f09cc to your computer and use it in GitHub Desktop.
top tier point differences
library(engsoccerdata)
library(tidyverse)
england %>%
filter(tier==1) %>%
split(.$Season) %>%
map(function(x) maketable_eng(x, Season = x$Season[1], tier=1, penalties=T) ) %>%
map(~summarise(., diff = Pts[Pos==1] - Pts[Pos==2])) %>%
bind_rows %>%
ggplot(aes(x=diff))+geom_histogram(color='black', fill="gray62", binwidth = 1) + scale_x_continuous(breaks = seq(0,20,2)) +
theme_bw() + ylab("Frequency") + xlab("Points difference") +
ggtitle("Final Points Difference Between 1st and 2nd in English Top Tier 1888-2018",subtitle = "Assumes 3 points for a win")
### which highest
england %>%
filter(tier==1) %>%
split(.$Season) %>%
map(function(x) maketable_eng(x, Season = x$Season[1], tier=1, penalties=T) ) %>%
map(~summarise(., diff = Pts[Pos==1] - Pts[Pos==2])) -> d
do.call('rbind', Map(cbind, d, Season = names(d))) %>%
arrange(-diff)
@jalapic
Copy link
Author

jalapic commented Apr 17, 2018

epl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment