Skip to content

Instantly share code, notes, and snippets.

@mrcaseb
mrcaseb / statsbomb.R
Created November 29, 2023 09:25
How to bring Statsbomb tracking data into a tidy form
## HOW TO USE THIS ##
# Go to https://github.com/statsbomb/amf-open-data/tree/main#getting-started
# and download the zipped json files containing the individual seasons, available via AWS S3
#
# Alternatively click the below links directly
# https://statsbomb-amf-open-data.s3.eu-west-2.amazonaws.com/tracking/SB_tracking_TB12DB_2021.zip
# https://statsbomb-amf-open-data.s3.eu-west-2.amazonaws.com/tracking/SB_tracking_TB12DB_2022.zip
#
# Unzip those files to a local directory. That directory will include deeply nested json files
@marcoarment
marcoarment / S3.php
Last active June 18, 2024 14:15
A simple PHP class to perform basic operations against Amazon S3 and compatible services.
<?php
/*
A simple PHP class to perform basic operations against Amazon S3 and compatible
services. Requires modern PHP (7+, probably) with curl, dom, and iconv modules.
Copyright 2022 Marco Arment. Released under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@nntrn
nntrn / espn-api-list.md
Last active December 26, 2024 17:54
List of nfl api endpoints from espn

List of NFL API Endpoints

This page has been updated a lot in the past 3 years. Older revisions you might like more than this one:

  • June 2021 - list of endpoints for other sports/leagues (i.e. basketball, baseball, lacrosse, rugby)
  • August 2021 - get historical fantasy league data
  • September 2021 - list of endpoints in plain text
  • May 2023 - collapsed endpoint response examples

Additional Resources

@steventroughtonsmith
steventroughtonsmith / MRDMenuView.h
Created March 1, 2020 17:21
Simplified iOS menu view wired up to UIMenuBuilder
//
// MRDMenuView.h
// MobileRadio
//
// Created by Steven Troughton-Smith on 29/02/2020.
// Copyright © 2020 High Caffeine Content. All rights reserved.
//
#import <UIKit/UIKit.h>
@guga31bb
guga31bb / box_score.md
Last active May 16, 2021 22:35
Make pretty box scores

Make box scores with EPA and other stuff

Code below. To get the game you want, need to choose season, type (regular, postseason, etc), home team, away team, and the rest will go on itself.

Code from @benbbaldwin

library(nflscrapR)
library(tidyverse)
library(na.tools)

Team Strength Exclusion Bias in Expected Points Models

@nflscrapR's Expected Points (EP) is a popular metric among analysts doing public research of play in the NFL. Detailed in the creators' research paper, the metric is derived from a model that was built as a part of a larger system designed to calculate individual wins above replacement values for offensive skill players.

The authors very graciously made public all of their data (nflscrapR-data) and code (nflWAR, nflscrapR-models, nflscrapR) for this project, including the code used to build the EP model. In the init_ep_fg_models.R file of the nflscrapR-models repository, we can see that the following variables are used

@guga31bb
guga31bb / nflscrapr.md
Last active August 18, 2023 07:45
Simple guide for using nflscrapR

THIS IS OUTDATED. PLEASE FOLLOW THE FOLLOWING LINK

--> A beginner's guide to nflfastR <--

Basic nflscrapR tutorial

I get a lot of questions about how to get nflscrapR up and running. This guide is intended to help new users build interesting tables or charts from the ground up, taking the raw nflscrapR data.

Quick word if you're new to programming: all of this is happening in R. Obviously, you need to install R on your computer to do any of this. Make sure you save what you're doing in a script (in R, File --> New script) so you can save your work and run multiple lines of code at once. To run code from a script, highlight what you want, right click, and select Run line. As you go through your R journey, you might get stuck and have to google a bunch of things, but that's totally okay and normal. That's how I wrote this thing!