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 / liverpool_age_utility.rmd
Last active February 14, 2022 15:49
Liverpool FC's Age-Utility Graph
## Packages
```{r}
library(rvest)
library(polite) # devtools::install_github("dmi3kno/polite")
library(dplyr)
library(tidyr)
library(ggplot2)
library(scales)
library(purrr)
@Ryo-N7
Ryo-N7 / tokyo_summer_temperature_heatmap.r
Last active August 19, 2018 03:28
Tokyo's historical summer temperature (heatmap) - original from Toyo Keizai Online
library(ggplot2)
library(dplyr)
library(tidyr)
library(purrr)
library(jsonlite)
library(lubridate)
library(magrittr)
library(scales)
library(stringr)
library(extrafont)
@Ryo-N7
Ryo-N7 / japan_sf_transition_animation.r
Last active August 21, 2018 13:54
Japan sf transitions animation
original viz link: https://gist.github.com/thomasp85/c36ab5cfe387dec9d5e99a85a776bfa0
# try to do above but with Japan instead!
library(gganimate)
library(cartogram)
library(geogrid) # devtools::install_github("jbaileyh/geogrid") >>> for sf support!
library(rnaturalearth)
library(sf)
library(scico)
@Ryo-N7
Ryo-N7 / jleague_avg_value_age.r
Last active February 15, 2021 16:13
J-League: Average Value vs. Average Age Plot
# saw these types of plots for different leagues on r/soccer
# (originally by Twitter: @fussbALEXperte)
# so thought I'd make my own version using R!
library(rvest)
library(polite)
library(dplyr)
library(tidyr)
library(purrr)
library(ggplot2)
@Ryo-N7
Ryo-N7 / tokyo_annual_temp_barcode_chart.r
Last active August 26, 2018 08:49
Bar Code Chart: Tokyo Annual Average Temperature (1876-2017)
# http://www.climate-lab-book.ac.uk/2018/warming-stripes/
# data from: http://www.data.jma.go.jp/obd/stats/etrn/view/annually_s.php?prec_no=44&block_no=47662
library(ggimage)
library(ggplot2)
library(dplyr)
library(tidyr)
library(purrr)
library(scales)
library(rvest)
@Ryo-N7
Ryo-N7 / japan_korea_rivalry.r
Last active October 17, 2018 13:25
Japan vs. Korea Soccer Rivalry Graph
library(polite)
library(rvest)
library(dplyr)
library(tidyr)
library(stringr)
library(lubridate)
library(ggplot2)
library(extrafont)
loadfonts() # run once per session
@Ryo-N7
Ryo-N7 / cranlogs_top_10_packages.r
Last active December 18, 2020 20:58
top 10 most downloaded r packages
library(dplyr)
library(tidyr)
library(ggplot2)
library(cranlogs)
library(ggtextures) # devtools::install_github("clauswilke/ggtextures")
library(extrafont)
loadfonts()
# top 10 package downloads from 9/29 to 10/28 from 'cranlogs' package
top_10_october <- cran_top_downloads(when = "last-month", count = 10)
@Ryo-N7
Ryo-N7 / kloppo.r
Created December 22, 2018 04:47
Klopp's Managerial History
pacman::p_load(tidyverse, scales, lubridate, ggrepel, glue, extrafont)
loadfonts()
lfc_elo_raw <- read_csv("http://api.clubelo.com/liverpool")
dortmund_elo_raw <- read_csv("http://api.clubelo.com/Dortmund")
mainz_elo_raw <- read_csv("http://api.clubelo.com/Mainz")
mainz_elo_clean <- mainz_elo_raw %>%
filter(between(From, as.Date("2001-02-28"), as.Date("2008-05-19")))
@Ryo-N7
Ryo-N7 / asian_cup_champions_viz.r
Last active January 4, 2019 10:09
Asian Cup champions!
pacman::p_load(tidyverse, scales, glue, extrafont, rvest, polite)
# Roboto Condensed font
loadfonts()
acup_url <- "https://en.wikipedia.org/wiki/AFC_Asian_Cup"
# responsible web-scraping ftw!
session <- bow(acup_url)
acup_winners_raw <- scrape(session) %>%
pacman::p_load(tidyverse, scales, glue, extrafont, rvest, ggtextures, cowplot, polite)
# Roboto Condensed font (from hrbrmstrthemes or just Google it)
loadfonts()
# web scrape
topg_url <- "https://en.wikipedia.org/wiki/AFC_Asian_Cup_records_and_statistics"
session <- bow(topg_url)
ac_top_scorers <- scrape(session) %>%