This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
dir_data <- file.path('inst', 'extdata', 'json') | |
paths <- | |
fs::dir_ls(dir_data, regexp = 'json$') | |
paths | |
n_path <- paths %>% length() | |
n_path | |
# paths <- 'inst/extdata/json/8-2020-1485311.json' | |
# paths <- 'inst/extdata/json/8-2019-1375927.json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Calculate the VAEP score for all actions in an atomic spadl df | |
#' @param spadl A df of spadl events | |
#' @param scores The name of a col of values calculated for the chance of scoring in next n actions | |
#' @param concedes The name of a col of values calculated for the chance of conceeding in next n actions | |
#' @param score_type Whether to score for the attacking contribution or defensive contribution | |
#' @export vaep_score_actions_atomic | |
#' @seealso vaep_score_actions | |
vaep_score_actions_atomic <- function(spadl, scores, concedes, score_type) { | |
#inverse formulas for attack and defense score |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* rs-theme-name: a Night Owl Tony */ | |
/* rs-theme-is-dark: TRUE */ | |
/* THIS THEME WAS AUTOGENERATED BY Theme.tmpl.css (UUID: EB0EC8F4-467B-46D0-8AE9-88B44F4D73B4) */ | |
.ace_gutter { | |
background: #011627; | |
color: #6C7A89; | |
} | |
.ace_print-margin { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ffscrapr) | |
library(ffsimulator) | |
library(ggplot2) | |
library(tonythemes) | |
conn <- espn_connect( | |
season = 2021, | |
league_id = 899513, | |
espn_s2 = Sys.getenv('FF_ESPN_S2'), | |
swid = Sys.getenv('FF_SWID') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* rs-theme-name: a fairyfloss tony */ | |
/* rs-theme-is-dark: TRUE */ | |
/* THIS THEME WAS AUTOGENERATED BY Theme.tmpl.css (UUID: D8D5E82E-3D5B-46B5-B38E-8C841C21347D) */ | |
.ace_gutter { | |
background: #494266; | |
color: #A19DAC; | |
} | |
.ace_print-margin { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tibble) | |
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
library(ggsankey) | |
df <- | |
tibble( | |
id = c( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Also see: | |
# - https://github.com/tonyelhabr/sports_viz/blob/master/44-mls_bangers/01-scrape.R | |
# - https://github.com/tonyelhabr/sports_viz/blob/master/44-mls_bangers/02-visualize.R | |
library(jsonlite) | |
library(dplyr) | |
library(janitor) | |
library(tibble) | |
library(lubridate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load packages | |
library(tidyverse) | |
library(metR) | |
library(nbastatR) | |
library(extrafont) | |
library(teamcolors) | |
library(cowplot) | |
# Custom theme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* rs-theme-name: a poolside tony */ | |
/* rs-theme-is-dark: TRUE */ | |
.ace_gutter { | |
background: #353454; | |
color: rgba(204, 204, 204, 0.7); | |
} | |
.ace_print-margin { | |
width: 2px; | |
background: rgba(204, 204, 204, 0.5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* rs-theme-name: a semi-cursive poolside tony */ | |
/* rs-theme-is-dark: TRUE */ | |
.ace_gutter { | |
background: #353454; | |
color: rgba(204, 204, 204, 0.7); | |
} | |
.ace_print-margin { | |
width: 2px; | |
background: rgba(204, 204, 204, 0.5); |