Skip to content

Instantly share code, notes, and snippets.

View Ryo-N7's full-sized avatar

Ryo Nakagawara Ryo-N7

View GitHub Profile
@ikashnitsky
ikashnitsky / world-cup-odds.R
Last active June 29, 2025 19:12
Were there too many unlikely results in Qatar? -- https://ikashnitsky.github.io/2022/exceptional-world-cup
#===============================================================================
# 2022-12-25 -- ik-q
# World cups -- was Qatar that exceptional?
# Ilya Kashnitsky, [email protected], @ikashnitsky
#===============================================================================
library(tidyverse)
library(magrittr)
library(wdman)
library(RSelenium)
library(tidycensus)
library(tidyverse)
options(tigris_use_cache = TRUE)
state_names <- c(state.name, "District of Columbia")
names(state_names) <- state_names
tictoc::tic()
age_maps <- map(state_names, ~{
@tonyelhabr
tonyelhabr / gamestate-xgd.md
Last active June 16, 2024 04:04
The correct way to calculate xG difference by gamestate

Here's some fake data showing how shot logs might look for a soccer match.

library(tibble)
library(dplyr)

df <- tibble::tibble(
  shot_id = seq.int(1, 8),
  minute = c(7, 13, 25, 30, 41, 44, 58, 78), ## doesn't matter, just for illustrative purposes
@JoGall
JoGall / fpl_xpts_draft_h2h.R
Created August 20, 2024 14:08
Expected Points (xPts) for FantasyPL draft head-to-head league
# Calculate expected points for a FantasyPL draft, head-to-head league.
#
# Calculate expected points (xPts) and expected rank (xRank) for each
# team in a head-to-head draft league as the average points (i.e. 0, 1, 3)
# expected against all teams in that league each gameweek, not just the actual
# opponent.
#
# @param leagueid: integer
library(dplyr)