Skip to content

Instantly share code, notes, and snippets.

View Ryo-N7's full-sized avatar

Ryo Nakagawara Ryo-N7

View GitHub Profile
@Ryo-N7
Ryo-N7 / check-action-sequence-statsbomb.R
Last active December 7, 2023 18:23
Check for specific sequence of actions in StatsBomb event data
library(soccermatics)
library(StatsBombR)
library(tidyverse)
library(ggsoccer)
matchesdf <- FreeMatches(FreeCompetitions()) %>% filter(competition.competition_id == 11, season.season_id == 90)
barhue <- matchesdf %>% filter(match_id == 3773369)
barhue_df <- get.matchFree(barhue) %>% allclean()
@Ryo-N7
Ryo-N7 / epl_topgoalscorers.Rmd
Last active May 7, 2020 11:05
Premier League Top Goalscorers by Minutes Played
# pkgs
```{r, message=FALSE, warning=FALSE}
pacman::p_load(dplyr, tidyr, purrr, scales,
ggplot2, ggtext, tibble, stringr,
glue, extrafont, ggbump, forcats)
loadfonts()
```
## raw data (scraped from transfermarkt)
@Ryo-N7
Ryo-N7 / progressive_pass_bundesliga_1920_hinrunde.Rmd
Last active May 6, 2020 07:01
Progressive Pass Plot (Bundesliga 2019-2020, Hinrunde)
# pkgs
```{r, message=FALSE, warning=FALSE}
pacman::p_load(tidyverse, polite, scales, ggimage,
ggforce, ggtext,
rvest, glue, extrafont, ggrepel, magick)
loadfonts()
```
## add_logo
@Ryo-N7
Ryo-N7 / xG_xA_plot_bundesliga_hinrunde.Rmd
Created January 14, 2020 10:04
np-xG per 90 vs. xA per 90 plot (Bundesliga 2019-2020, Hinrunde)
# pkgs
```{r, message=FALSE, warning=FALSE}
pacman::p_load(tidyverse, scales, ggforce, ggtext,
rvest, glue, extrafont, ggrepel, magick)
loadfonts()
```
## add_logo
@Ryo-N7
Ryo-N7 / xG_xA_plot_MD21.Rmd
Last active May 6, 2020 07:01
np-xG per 90 vs. xA per 90
# pkgs
```{r, message=FALSE, warning=FALSE}
pacman::p_load(tidyverse, polite, scales, ggimage,
ggforce, ggtext,
rvest, glue, extrafont, ggrepel, magick)
loadfonts()
```
## add_logo
# pkgs
```{r, message=FALSE, warning=FALSE}
pacman::p_load(tidyverse, polite, scales, ggimage,
ggforce, ggtext,
rvest, glue, extrafont, ggrepel, magick)
loadfonts()
```
## add_logo
@Ryo-N7
Ryo-N7 / lewandoski_shot_contrib_hinrunde1920.r
Created December 24, 2019 08:43
Lewandowski Shot Contribution (Hinrunde 2019-2020)
## Twitter: @R_by_Ryo
## Website: ryo-n7.github.io
## Packages
pacman::p_load(ggplot2, dplyr, glue, extrafont, ggrepel, magick, ggtext)
loadfonts(quiet = TRUE)
## load data
lewa_shot_contrib <- readRDS(url("https://raw.githubusercontent.com/Ryo-N7/soccer_ggplots/master/data/lewa_shot_contrib.RDS"))
@Ryo-N7
Ryo-N7 / viz_epl_part_two.R
Last active December 1, 2019 09:56
Visualize the EPL, Part 2
####
# Will keep updating this so if everything isn't there yet please be patient!
####
## Packages
pacman::p_load(tidyverse, polite, scales, ggimage, ggforce,
understatr, cowplot, kableExtra, ggbeeswarm,
jsonlite, xml2, qdapRegex, stringi, stringr,
rvest, glue, extrafont, ggrepel, magick, ggtext)
@Ryo-N7
Ryo-N7 / viz_epl_part_one.R
Last active November 21, 2019 09:43
Visualize the EPL, Part 1
## Packages
pacman::p_load(tidyverse, polite, scales, ggimage, ggforce,
understatr, cowplot, kableExtra, ggbeeswarm,
jsonlite, xml2, qdapRegex, stringi, stringr,
rvest, glue, extrafont, ggrepel, magick, ggtext)
loadfonts(quiet = TRUE)
## xPts Table
premierleague2019 <- get_league_teams_stats("EPL", 2019)
## NON-PENALTY xG
@Ryo-N7
Ryo-N7 / age_utility_LFC_1920.r
Last active November 16, 2019 08:01
Liverpool FC Age-Utility Graph (Premier League 2019-2020)
pacman::p_load(tidyverse, polite, scales, ggimage, ggforce,
stringr, ggtext,
rvest, glue, extrafont, ggrepel)
loadfonts(quiet = TRUE)
session <- bow("https://www.transfermarkt.com/liverpool-fc/leistungsdaten/verein/31/reldata/GB1%262019/plus/1")
print(session)
result_name <- scrape(session) %>%
html_nodes("#yw1 .bilderrahmen-fixed") %>%