Skip to content

Instantly share code, notes, and snippets.

View Ryo-N7's full-sized avatar

Ryo Nakagawara Ryo-N7

View GitHub Profile
@tjmahr
tjmahr / chess-moves.md
Created May 28, 2019 16:27
chess moves
library(tidyverse)
theme_set(theme_minimal())

mt <- read.csv(url('https://gist.githubusercontent.com/ashtonanderson/cfbf51e08747f60472ee2132b0d35efb/raw/80acd2ad7c0fba4e85c053e61e9e5457137e00ee/moveno_piecetype_counts'))

mt$piece_type <- factor(
  mt$piece_type, 
  levels = c("P","N","B","Q","R","O","K"),
  labels = c(
@uribo
uribo / population_and_flood_damage_biscale.R
Last active June 4, 2019 10:15
東京23区1kmメッシュにおける人口総数と想定浸水深の可視化
library(sf)
library(ensurer)
library(assertr)
library(dplyr)
library(fgdr)
library(jpmesh)
library(readr)
library(ggplot2)
library(cowplot)
library(biscale)
@eliocamp
eliocamp / tweet_storm.R
Last active December 3, 2024 23:01
Example of posting a twitter thread from R
---
title: "Tweet thread"
author: "Elio Campitelli"
output: github_document
---
```{r}
knitr::opts_chunk$set(dev = "png",
tweet_this = TRUE)
#===============================================================================
# 2019-07-19-- ikashnitsky.github.io
# Reproduce Figure 2 from http://doi.org/10.1007/s10708-018-9953-5
# Ilya Kashnitsky, [email protected]
#===============================================================================
library(tidyverse)
library(hrbrthemes); import_roboto_condensed()
# the data as tribble
@emitanaka
emitanaka / collapseoutput.js
Created July 20, 2019 04:43
Collapsible Code Output for `xaringan`
<script>
(function() {
var divHTML = document.querySelectorAll(".details-open");
divHTML.forEach(function (el) {
var preNodes = el.getElementsByTagName("pre");
var outputNode = preNodes[1];
outputNode.outerHTML = "<details open class='output'><summary>Output</summary>" + outputNode.outerHTML + "</details>";
})
})();
(function() {

Introduction

"Footedness" is a concept you're probably familiar with. Players almost always naturally prefer to dribble / shoot / pass with a certain foot. Total ambidexterity (being as comfortable using one foot as the other) is rarer, but is common enough at the top level.

One of the ways in which we can quantify footedness for a player is looking at how many shots or goals the player scores using one foot vs. the other. However, this isn't that meaningful for us because the majority of the time, we can see with our own eyes which foot a player prefers.

On the other hand, footedness of teams is more interesting to me. Here I've looked at which teams prefer one foot over the other or are ambidextrous, using a new metric I've called the "Ambidexterity Index" (AI). The source for all data described here is Understat; full credit to them.


@elliottmorris
elliottmorris / election_night_live_model.R
Last active January 29, 2024 18:56
A live election-night prediction model using The Economist's pre-election forecast
#' Description
#' This file runs a live election-night forecast based on The Economist's pre-election forecasting model
#' available at projects.economist.com/us-2020-forecast/president.
#' It is resampling model based on https://pkremp.github.io/update_prob.html.
#' This script does not input any real election results! You will have to enter your picks/constraints manually (scroll to the bottom of the script).
#'
#' Licence
#' This software is published by *[The Economist](https://www.economist.com)* under the [MIT licence](https://opensource.org/licenses/MIT). The data generated by *The Economist* are available under the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/).
#' The licences include only the data and the software authored by *The Economist*, and do not cover any *Economist* content or third-party data or content made available using the software. More information about licensing, syndication and the copyright of *Economist* content can be fou
``` r
library(ggplot2)
library(dplyr)
library(magick)
library(patchwork)
library(gt)
library(ggtext)
mtcars %>%
head() %>%
@uribo
uribo / jma_normal_phenology.R
Created March 31, 2021 14:47
生物季節観測 さくらの開花日・満開日の期間
####################################
# 月*100+日
# 9月5日 --> 905
####################################
library(readr)
library(dplyr)
library(ggplot2)
library(ggalt)
d <-
read_csv("~/Downloads/normal_phenology/nml_phenology.csv",
@juliasilge
juliasilge / internet_access.md
Created May 12, 2021 03:34
#TidyTuesday internet access in the US
library(tidyverse)
library(tidycensus)
library(sf)
#> Linking to GEOS 3.8.1, GDAL 3.1.4, PROJ 6.3.1
library(viridis)
#> Loading required package: viridisLite
library(patchwork)
theme_set(silgelib::theme_plex())