Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@jalapic jalapic commented Apr 17, 2018

epl

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