Skip to content

Instantly share code, notes, and snippets.

@jalapic
Created May 21, 2017 18:44
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/bb5223a74c95a1e2478c607cf19c6773 to your computer and use it in GitHub Desktop.
Save jalapic/bb5223a74c95a1e2478c607cf19c6773 to your computer and use it in GitHub Desktop.
6 goals in consecutive away games
library(tidyverse)
library(engsoccerdata)
england %>%
filter(tier==1) %>%
homeaway() %>%
group_by(team) %>%
arrange(Date) %>%
filter(venue=="away") %>%
mutate(gameno = row_number())%>%
filter(gf>=6) %>%
mutate(gamedif = gameno- Hmisc::Lag(gameno)) %>%
filter(gamedif==1 | lead(gamedif)==1)
# Date Season team opp gf ga division tier venue gameno gamedif
# <date> <dbl> <chr> <chr> <int> <int> <chr> <dbl> <chr> <int> <int>
# 1 1892-09-03 1892 Sunderland Accrington F.C. 6 0 1 1 away 25 2
# 2 1892-09-17 1892 Sunderland Aston Villa 6 1 1 1 away 26 1
# 3 1961-09-16 1961 Burnley Birmingham City 6 2 1 1 away 722 18
# 4 1961-09-20 1961 Burnley Leicester City 6 2 1 1 away 723 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment